1
這裏的「Name」的正則表達式包含a-z,0-9, - ,_?jQuery驗證器中名稱的正則表達式
$.validator.addMethod("validName",
function(value, element) {
return /.....*/.test(value);
},
"Invalid name"
);
這裏的「Name」的正則表達式包含a-z,0-9, - ,_?jQuery驗證器中名稱的正則表達式
$.validator.addMethod("validName",
function(value, element) {
return /.....*/.test(value);
},
"Invalid name"
);
你可能想這樣的:
return /^[a-z0-9\-_]+$/.test(value);
它測試的字符串包含那些字符,並沒有其他的字符中的至少一個(在^
和$
是開始和字符串錨的結束)。
如果你想允許定期空間()和點,使用
return /^[a-z0-9\-_\ \.]+$/.test(value);
如何將和呢? –
user2176764
2013-03-22 19:01:46
請參閱編輯。 [this reference](http://www.regular-expressions.info/reference.html)也可能有用。 – 2013-03-22 19:04:45