jQuery验证与MVC3剃刀中的规则 [英] jquery validation with rules in mvc3 razor

查看:56
本文介绍了jQuery验证与MVC3剃刀中的规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要chk确认密码是否等于jquery规则的密码.

首先尝试使用文档准备功能,以使其正常工作.
编码是,

Hi,

I need to chk the confirm password is equal to password or not with jquery rules.

first am tried with document ready function that time its working properly.
the coding are,

$(document).ready(function () {
<pre lang="cs">$(&quot;#frmSite&quot;).validate(
       {
        rules: {
        confirm password: {
        equalTo: &quot;#password&quot;
        }
      },
     messages: {
     confirm password: {
     equalTo:&quot;Password is not match&quot;
     }
   }
});</pre>


});

这是正常工作..
但是在按钮点击功能中使用了相同的编码


});

This is working correctly..
but the same coding am used in button click function

$('#btnSiteSave').click(function (e) {
                 $("#frmSite").validate(
       {
        rules: {
        DaysinWeek: {
        equalTo: "#GMT"
        }
      },
     messages: {
     DaysinWeek: {
     equalTo:"Password is not match"
     }
   }
});
    });



如果在click函数中提供相同的编码,则无法正常工作.
请帮助我解决此问题.



if am giving the same coding in click function its not working.
Please help me to solve this problem.

推荐答案

(document).ready(function(){ < pre =" cs"
(document).ready(function () { <pre lang="cs">


(&"#frmSite& quot;).validate( { 规则:{ 确认密码: { equalTo:& quot;#password& quot; } }, 讯息:{ 确认密码: { equalTo:"密码不匹配" } } }); < /pre >
(&quot;#frmSite&quot;).validate( { rules: { confirm password: { equalTo: &quot;#password&quot; } }, messages: { confirm password: { equalTo:&quot;Password is not match&quot; } } });</pre>


});

这是正常工作..
但是在按钮点击功能中使用了相同的编码


});

This is working correctly..
but the same coding am used in button click function


(' #btnSiteSave').click(function(e){
('#btnSiteSave').click(function (e) {


这篇关于jQuery验证与MVC3剃刀中的规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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