问题描述
我是Knockout MVC的新手。
我想检查密码并比较密码。在将数据保存到数据库之前必须相同。我正在使用'jquery.validate.js'其他验证。
我也想用这个js进行比较验证。有没有办法用'jquery.validate.js'js进行比较验证?
以下是我的代码:
密码:@ ko.Html.Password(m => m.Password,new {id = txtPassword,@ class =required})。ValueUpdate(KnockoutValueUpdateKind.AfterKeyDown)
确认密码:@ ko.Html.Password(m => m .ConfirmPassword,new {id =txtConfirmPassword,@ class =required,validateDelegate =password equalTo})。ValueUpdate(KnockoutValueUpdateKind.AfterKeyDown)
和我也使用脚本。
< script type =text / javascript>
$(#MyForm)。ajaxForm ();
规则:{
passwo rd:required,
confirmPassword:{equalTo:#txtPassword}
}
$(#MyForm)。validate ({submitHandler:function(){@ ko.ServerAction(Save,SaveData); }});
< / script>
此代码在浏览器的控制台中为相关令牌标识符引发错误
I am newbie to Knockout MVC.
I want to check password and compare password.It must be same before going to save the data in database.I am using 'jquery.validate.js' for other validation.
And i want to use this js for compare validation also.Is there any way to use 'jquery.validate.js' js for compare validation?
Below is my code :
Password: @ko.Html.Password(m => m.Password, new { id = "txtPassword", @class = "required" }).ValueUpdate(KnockoutValueUpdateKind.AfterKeyDown)
Confirm Password: @ko.Html.Password(m => m.ConfirmPassword, new { id = "txtConfirmPassword", @class = "required", validateDelegate = "password equalTo" }).ValueUpdate(KnockoutValueUpdateKind.AfterKeyDown)
and i use Script also.
<script type="text/javascript">
$("#MyForm").ajaxForm();
rules: {
password: "required",
confirmPassword : {equalTo: "#txtPassword"}
}
$("#MyForm").validate({ submitHandler: function () { @ko.ServerAction("Save", "SaveData"); } });
</script>
This code throw me an error for related token identifier in Browser's Console
推荐答案
这篇关于比较knockoutMvc中的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!