jQuery中的正则表达式字段验证 [英] Regular expression field validation in jQuery
问题描述
在jQuery中,有没有一个函数/插件可用于匹配字符串中的给定正则表达式?
In jQuery, is there a function/plugin which I can use to match a given regular expression in a string?
例如,在电子邮件输入框中,我获得了一个电子邮件地址,并想查看其格式是否正确.我应该使用什么jQuery函数查看我的验证正则表达式是否与输入匹配?
For example, in an email input box, I get an email address, and want to see if it is in the correct format. What jQuery function should I use to see if my validating regular expression matches the input?
我已经在谷歌上寻找解决方案,但是我什么都找不到.
I've googled for a solution, but I haven't been able to find anything.
推荐答案
我相信这样做:
http://bassistance.de/jquery-plugins/jquery-plugin-validation /
它具有用于URL和电子邮件地址之类的内置模式,我想您也可以使用自己的模式.
It's got built-in patterns for stuff like URLs and e-mail addresses, and I think you can have it use your own as well.
这篇关于jQuery中的正则表达式字段验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!