commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / bower_components / jquery-validation / src / additional / pattern.js
1 /**
2 * Return true if the field value matches the given format RegExp
3 *
4 * @example $.validator.methods.pattern("AR1004",element,/^AR\d{4}$/)
5 * @result true
6 *
7 * @example $.validator.methods.pattern("BR1004",element,/^AR\d{4}$/)
8 * @result false
9 *
10 * @name $.validator.methods.pattern
11 * @type Boolean
12 * @cat Plugins/Validate/Methods
13 */
14 $.validator.addMethod("pattern", function(value, element, param) {
15 if (this.optional(element)) {
16 return true;
17 }
18 if (typeof param === "string") {
19 param = new RegExp("^(?:" + param + ")$");
20 }
21 return param.test(value);
22 }, "Invalid format.");