-
Notifications
You must be signed in to change notification settings - Fork 24
@PasswordsMatch
troyji edited this page Aug 16, 2011
·
10 revisions
@PasswordsMatch
is a form-specific constraint that ensures that the values of the specified password fields match.This constraint can only be attached to forms. Attaching it to regular input elements will result in an error.
Syntax for @PasswordsMatch
is:
@PasswordsMatch(field1=id-of-first-password-field, field2=id-of-second-password-field
[label=label-text] , [message=message-text] , [groups=array-of-group-names])
Name | Type | Required | Description |
---|---|---|---|
field1 |
String | yes | A required parameter that specifies the id of the first password field. |
field2 |
String | yes | A required parameter that specifies the id of the second password field. |
label |
String | no | An optional parameter that specifies the label for this input element. Labels are a way to provide friendly names to input elements. If the constraint fails to validate, the value in this field will be used in the default error message. If the constraint has a custom error message which contains {labe} , the value of this parameter will be substituted in the place of {label} . |
message |
String | no | An optional parameter that specifies the error message to use when this constraint fails. The value for this field can contain interpolations of parameters used by the constraint . For example: {label} needs to be {param1} . |
groups |
Array | no | An array of group names that specifies the validation groups that this constraint belongs to. |
<form id = "myForm"
name = "myForm"
...
data-constraints = '@PasswordsMatch(field1="password", field2="confirmationPassword")'>
...
...
Enter a password: <input id = "password1" name = "password1" type = "password" />
Confirm your password: <input id = "password2" name = "password2" type = "password" />
...
...
</form>
<form id = "myForm"
name = "myForm"
...
data-constraints = '@PasswordsMatch(field1="password", field2="confirmationPassword"
message="Your passwords do not match", groups=[FirstGroup, SecondGroup, ThirdGroup])'>
...
...
Enter a password: <input id = "password1" name = "password1" type = "password" />
Confirm your password: <input id = "password2" name = "password2" type = "password" />
...
...
</form>