-
Notifications
You must be signed in to change notification settings - Fork 24
@Future
vivin edited this page Jul 19, 2012
·
3 revisions
@Future
enforces the constraint that the date value of the input element must be in the future.
Syntax for @Future
is:
@Future(format=format-value, [label=label-text] ,
[message=message-text] ,
[groups=array-of-group-names])
Name | Type | Required | Description |
---|---|---|---|
format |
String | yes | A required parameter that specifies the format of the date. String representations of any of the values in DateFormat are acceptable. |
separator |
String | no | An optional parameter that specifies the separator between the months, years, and days in a date. If one is not provided, Regula will attempt to guess the separator in the following order: slash, dot, space, any non-numeric character. |
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 {label} , 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 less than or equal to {value} . |
groups |
Array | no | An array of group names that specifies the validation groups that this constraint belongs to. |
<input id = "reservationDate"
name = "reservationDate"
type = "text"
data-constraints = '@Future(format="MDY")' />
<input id = "reservationDate"
name = "reservationDate"
type = "text"
data-constraints = '@Future(format="MDY",
label="reservation date",
message="The {label} needs to be in the future",
groups=[FirstGroup, SecondGroup, ThirdGroup]' />
Programmatic binding (shows the usage of DateFormat):
regula.bind({
element: document.getElementById("reservationDate"),
constraints: [
{constraintType: regula.Constraint.Future,
params: {format: regula.DateFormat.MDY, message: "The reservation date be in the future."}
}
]
});