jQuery的验证器插件,而无需使用形式 [英] jQuery validator plugin without using form

查看:97
本文介绍了jQuery的验证器插件,而无需使用形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个部分是asp.net,在大块数据提交,我想使用jQuery验证插件,但问题是,asp.net包装的一切形式和子窗体不工作呢权,技术上不正确。

I have multiple section is asp.net that submits data in chunk and i want to use jquery validation plugin, but issue is that asp.net wraps everything in form and child forms not wokring right and technically incorrect.

所以,唯一的选择就是忘记形式和实施验证的div的。但是,所有萨姆斯我看到正在使用的形式。由于不是在jQuery的不好我无法弄清楚如何使用此验证页(在DIV)的部分。

So only alternative is forget about form and implement validation for divs. But all sames i see are using form. As not being not good at jquery i can't figure out how to use this validator on section of page(On div).

这可能吗?或任何其他好的选择?

Is it possible? or any other good alternative?

来源:
http://bassistance.de/jquery-plugins/jquery-plugin-validation/

推荐答案

像nightingale2k1说,你应该能够使用该插件就好用一种形式。下面是一个使用DIV,而不是一个简单的例子:

Like nightingale2k1 said, you should be able to use that plug-in just fine with a FORM. Here's a quick example that uses a DIV instead:

<div id="pseudoForm">
  <input type="text" name="first_name"/>
  <input type="text" name="last_name"/>
</div>
<script type="text/javascript">
  $("#pseudoForm").validate({
    onfocusout:true,
    rules:{
      first_name:"required",
      last_name:"required"
    });
</script>

注意我是如何用onfocusout在:真正的,这将使得插件验证当用户去选择其中一个元素。你需要的将是使用类似的东西,要不然挂钩自己的事件(可能在响应按钮preSS)的验证被触发,因为正常触发(的onsubmit)是不适用的DIV

Notice how I used "onfocusout:true", which will make the plug-in validate when the user de-selects either element. You'll need to either use something like that, or else hook up your own event (probably in response to a button press) for the validation to be triggered, as the normal trigger (onSubmit) isn't applicable to DIVs.

这篇关于jQuery的验证器插件,而无需使用形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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