jQuery中的正则表达式字段验证 [英] Regular expression field validation in jQuery

查看:69
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆