-1
$.validator.addMethod(
"regex",
function(value, element, regexp) {
var re = new RegExp(regexp);
return this.optional(element) || re.test(value);
},
"Please check your input."
);
$.validator.addClassRules({
link:{
required: true,
regex: "(https?:\/\/(www\.))?[[email protected]:%._\+~#=]{2,256}\.[a-z]{2,4}\b([[email protected]:%_\+.~#?&//=]*)"
},
});
正規表現が文字列の頂点を分割して動作しないと思います。どうすればこの問題を解決できますか?jqueryバリデータでの正規表現の使用
正規表現のリテラル構文を使用します。囲み引用符を '/'で置き換えます。 – Tushar