使用 jQuery 检查正则表达式
我知道有 jQuery 验证插件。但我不需要那么广泛的东西。
我想要做的就是让 jQuery 检查名称文本框:
<input type="text" name="name" id="name" />
以确保它至少有 2 个字符
,并且
我希望 jQuery 检查电话文本框(与名称文本框相同,name="phone" 和 id= “phone”),以确保它只包含数字,无论有多少个数字。
最后,只有在这不太难完成的情况下,我希望 jQuery 验证电子邮件地址以检查并确保其中包含字符“@”。
这太难做到了吗?
谢谢, 阿米特
I know there's the jQuery validation plugin. But I don't need something that extensive.
All I want to do is have jQuery check a name text box:
<input type="text" name="name" id="name" />
To make sure that it has at least 2 characters
AND
I want jQuery to check a phone text box (identical to the name text box, name="phone" and id="phone"), to make sure that it only contains numbers, doesn't matter how many numbers.
Finally, and this is only if this is not too hard to accomplish, I want jQuery to validate the email address to check and make sure that it has the character '@' in it.
Is this too hard to do?
Thanks,
Amit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 jQuery 验证插件过于广泛,这里有一个更简单的插件。
If the jQuery validation plugin is too extensive, here's an even simpler one.