开发者

jQuery Validation for Text box

I want to validate the textbox which should accept only "letters" and "." and "/".

how to do this using jquery plugin?

thanks in ad开发者_如何学Govance.jquery vlidt


You will need to extend the validation plugin to use a regular expression as discussed in this post here: StackOverflow

    $.validator.addMethod( 
        "regex", 
        function(value, element, regexp) { 
            var check = false; 
            var re = new RegExp(regexp); 
            return this.optional(element) || re.test(value); 
        }, 
        "Please check your input." 
); 

$("Textbox").rules("add", { regex: "^[a-zA-Z./]+" })  - I think this reg expression is right...?

And for your specific example, a list of regular expressions can be found here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜