Всем привет!
Есть плагин валидации: jquery validate
В нём можно устанавливать правила, чтоб проверка перед сохранением была:
Цитата |
rules (default: rules are read from markup (classes, attributes, data)) Type: Object Key/value pairs defining custom rules. Key is the name of an element (or a group of checkboxes/radio buttons), value is an object consisting of rule/parameter pairs or a plain String. Can be combined with class/attribute/data rules. Each rule can be specified as having a depends-property to apply the rule only in certain conditions. See the second example below for details. Example: Specifies a name element as required and an email element as required (using the shortcut for a single rule) and a valid email address (using another object literal). |
<input type="text" id="birthday" class="calendar">
<input type="text" id="date1" class="calendar">
<input type="text" id="date2" class="calendar">
...
$(".selector").validate({
rules: {
birthday: {dpDate: true},
date1: {dpDate: true},
date2: {dpDate: true}
},
messages: {
birthday: 'Введите допустимое значение даты',
date1: 'Введите допустимое значение даты',
date2: 'Введите допустимое значение даты'
}
});