Subversion-Projekte lars-tiefland.zeldi.de

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 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." );