使用jQuery Validation插件验证不在表单内的输入 [英] Validate inputs that are not inside a form with jQuery Validation plugin
问题描述
如何验证不在表单标记内的某些输入?
How can I validate some inputs that are not inside a form tag?
我找到的所有示例都有一个表单标记,但我想验证一些输入不在表格内。
All the samples I found have a form tag, but I want to validate some inputs that are not inside a form.
推荐答案
以前接受的答案(自删除后)链接到插件这是最后一次更新于2009年1月。这个过时的插件与 OP询问的插件非常不同:
The previously accepted answer (since deleted) was linking to a plugin that was last updated in January 2009. This obsolete plugin is very different than the plugin the OP was asking about:
标题:使用jQuery Validation插件验证不在表单内的输入
Title: "Validate inputs that are not inside a form with jQuery Validation plugin"
标记: jquery-validate
使用 jQuery Validate插件,无法验证< form><< form>< / form>
容器。 此限制没有解决方法。
DEMO 1 :使用<$ c $显示正确的用法c>表格容器。
<form id="myform">
<input type="text" name="myinput" />
<input type="submit" />
</form>
DEMO 2 :显示表单
容器已更改为 div
,相同的代码现已完全损坏。如果没有表格
容器,该插件什么都不做。
DEMO 2: Shows the form
container changed into a div
and the same code is now totally broken. The plugin does nothing without a form
container.
<div id="myform">
<input type="text" name="myinput" />
<input type="submit" />
</div>
http://jsfiddle.net/nswnomn6/1/
你唯一的选择是是使用不同的jQuery插件进行表单验证。不幸的是,我知道没有jQuery表单验证插件可以让你验证< form>
容器之外的输入元素。
Your only alternative would be to use a different jQuery plugin for form validation. Unfortunately, I know of no jQuery form validation plugin that would allow you to validate input elements outside of a <form>
container.
这篇关于使用jQuery Validation插件验证不在表单内的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!