Resource for test regular expression.
Examples lookin for into js/prototype/validation.js
on line 414 and there you can add newcustom validation pattern.
['{className}', '{error message}', function(v) {
return Validation.get('IsEmpty').test(v) || /{regular expression}/.test(v);
}],
where:
- {className} - class name what will be added to field for checking field value on this pattern
- {error message} - message what will see user if validation not passed
- {regular expression} - regular expression for check field value
['validate-phone', 'Please enter a valid phone number. For example +38 (999) 999-99-99.', function(v) {
return Validation.get('IsEmpty').test(v) || /^(\+(38)\s)?(\(\d{3}\))?\s?(\d{3}[-. ]?\d{2}[-. ]?\d{2})$/.test(v);
}],
['validate-phone', 'Please enter a valid phone number. For example +7 (999) 999-99-99.', function(v) {
return Validation.get('IsEmpty').test(v) || /^(\+\d\s)?(\(\d{3}\))?\s?(\d{3}[-. ]?\d{2}[-. ]?\d{2})$/.test(v);
}],