清除验证目的 [英] Clearing Validation Purpose

查看:135
本文介绍了清除验证目的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





这是我的观点





< br $> b $ b

学校有员工房吗? 
@ Html.RadioButtonFor(model = > model.charSchoolHaveStaffHouses, Y new {onclick = StaffHouses_Click(),name = rdoSchStaffHostel,id = rdoSchStaffHousesY})是
@ Html.RadioButtonFor(model = > model.charSchoolHaveStaffHouses, N new {onchanged = valid(), onclick = $(this).resetValidation()})No
@Html。 ValidationMessageFor(model = > mod el.charSchoolHaveStaffHouses)
学校有多少员工房?
@ Html.TextBoxFor(model = > model.intStaffHousesCount, new {disabled = < span class =code-string> disabled,maxlength = 4 ,onkeypress = return validate(event),@ class = myStyle})
@ Html.ValidationMessageFor(model = > model.intStaffHousesCount)
No Of Workers in the Staff Houses

@ Html.TextBoxFor(model = > model.intWorkersCountInStaffHouses, new {disabled = disabled,maxlength = 4 ,onkeypress = < span class =code-stri ng> return validate(event),@ class = myStyle})
@ Html.ValidationMessageFor(model = > model.intWorkersCountInStaffHouses)







我在这个视图中调用JavaScript函数如下



 function StaffHouses_Click( ){
var radio1 = document.getElementById( rdoSchStaffHousesY);
var radio2 = document.getElementById( charSchoolHaveStaffHouses);
if (radio1。 checked == true ){
document.getElementById( intStaffHousesCount)。disabled = < span class =code-keyword> false
;
document.getElementById( intWorkersCountInStaffHouses)。disabled = ;
}
else {
document.getElementById( intStaffHousesCount)。disabled = true ;
document.getElementById( intWorkersCountInStaffHouses)。disabled = ;
document.getElementById( intStaffHousesCount)。 value = ;
document.getElementById( intWorkersCountInStaffHouses)。 value = ;


$(' #intStaffHousesCount .input-validation-error')。addClass(' input-validation-valid');
$(' #intStaffHousesCount .input-validation-error')。removeClass(' input-validation-error');

$(' #intStaffHousesCount .field-validation-error')。 addClass(' field-validation-valid');
$(' #intStaffHousesCount .field-validation-error')。removeClass(' field-validation-error');

$(' #intStaffHousesCount .validation-summary-errors')。 addClass(' validation-summary-valid');
$(' #intStaffHousesCount .validation-summary-errors')。removeClass(' validation-summary-errors');

// $('#field-validation-error ui-state-error-icon ui-icon-alert')。removeClass。

// document。 getElementById(intStaffHousesCount)。onerror.value.disabled = true;

}
}



所以In这个我想在控制处于禁用模式时清除验证错误,即当我们点击没有2个文本框时在开始时提到的单选按钮应该被禁用并且应该清除错误提供者。所以请为此提供解决方案? ?





提前致谢

解决方案

(this).resetValidation ()})否
@ Html.ValidationMessageFor(model = > model.charSchoolHaveStaffHouses)
有多少员工住宅学校有?
@ Html.TextBoxFor(model = > model.intStaffHousesCount, new {disabled = 已停用,maxlength = 4 ,onkeypress = return validate(event),@ class = myStyle})
@ Html.ValidationMessageFor(model = > model.intStaffHousesCount)
No of Workers in 员工住宅

@ Html.TextBoxFor(model = > model.intWorkersCountInStaffHouses, new {disabled = disabled,maxlength = 4 ,onkeypress = return validate(event),@ class =
myStyle})
@ Html.ValidationMessageFor(model = > model.intWorkersCountInStaffHouses)







我在这个视图中调用JavaScript函数如下< br $>


 function StaffHouses_Click(){
var radio1 = document .getElementById( rdoSchStaffHousesY);
var radio2 = document.getElementById( charSchoolHaveStaffHouses);
if (radio1。 checked == true ){
document.getElementById( intStaffHousesCount)。disabled = < span class =code-keyword> false
;
document.getElementById( intWorkersCountInStaffHouses)。disabled = ;
}
else {
document.getElementById( intStaffHousesCount)。disabled = true ;
document.getElementById( intWorkersCountInStaffHouses)。disabled = ;
document.getElementById( intStaffHousesCount)。 value = ;
document.getElementById( intWorkersCountInStaffHouses)。 value = ;


' #intStaffHousesCount .input-validation-error')。addClass(' input-validation-valid');


' #intStaffHousesCount .input-validation-error')。removeClass(' 输入验证错误');

Hi,

This is my view




Does the school have staff houses? 	
@Html.RadioButtonFor(model => model.charSchoolHaveStaffHouses, "Y", new { onclick = "StaffHouses_Click()", name = "rdoSchStaffHostel", id = "rdoSchStaffHousesY" })Yes
@Html.RadioButtonFor(model => model.charSchoolHaveStaffHouses, "N", new {onchanged="valid()", onclick = " $(this).resetValidation()" })No
@Html.ValidationMessageFor(model => model.charSchoolHaveStaffHouses)
How many Staff Houses does the school have? 	
@Html.TextBoxFor(model => model.intStaffHousesCount, new { disabled = "disabled", maxlength = 4, onkeypress = "return validate(event)", @class = "myStyle" })
@Html.ValidationMessageFor(model => model.intStaffHousesCount)
No Of Workers in the Staff Houses 	
 
@Html.TextBoxFor(model => model.intWorkersCountInStaffHouses, new { disabled = "disabled", maxlength = 4, onkeypress = "return validate(event)", @class = "myStyle" })
@Html.ValidationMessageFor(model => model.intWorkersCountInStaffHouses)




and I am calling JavaScript functions in this view as follows

function StaffHouses_Click() {
var radio1 = document.getElementById("rdoSchStaffHousesY");
var radio2 = document.getElementById("charSchoolHaveStaffHouses");
if (radio1.checked == true) {
document.getElementById("intStaffHousesCount").disabled = false;
document.getElementById("intWorkersCountInStaffHouses").disabled = false;
}
else {
document.getElementById("intStaffHousesCount").disabled = true;
document.getElementById("intWorkersCountInStaffHouses").disabled = true;
document.getElementById("intStaffHousesCount").value = "";
document.getElementById("intWorkersCountInStaffHouses").value = "";
 

$('#intStaffHousesCount .input-validation-error').addClass('input-validation-valid');
$('#intStaffHousesCount .input-validation-error').removeClass('input-validation-error');
 
$('#intStaffHousesCount .field-validation-error').addClass('field-validation-valid');
$('#intStaffHousesCount .field-validation-error').removeClass('field-validation-error');

$('#intStaffHousesCount .validation-summary-errors').addClass('validation-summary-valid');
$('#intStaffHousesCount .validation-summary-errors').removeClass('validation-summary-errors');
 
//$('#field-validation-error ui-state-error-icon ui-icon-alert').removeClass.
 
//document.getElementById("intStaffHousesCount").onerror.value.disabled = true;
 
}
}


So In this I want to clear the validation errors when the control is in disable mode i.e when the radio button which is mentioned in the starting when we click on no 2 textboxes should be disabled and error providers should be cleared.So please provide solution for this??


Thanks in advance

解决方案

(this).resetValidation()" })No @Html.ValidationMessageFor(model => model.charSchoolHaveStaffHouses) How many Staff Houses does the school have? @Html.TextBoxFor(model => model.intStaffHousesCount, new { disabled = "disabled", maxlength = 4, onkeypress = "return validate(event)", @class = "myStyle" }) @Html.ValidationMessageFor(model => model.intStaffHousesCount) No Of Workers in the Staff Houses @Html.TextBoxFor(model => model.intWorkersCountInStaffHouses, new { disabled = "disabled", maxlength = 4, onkeypress = "return validate(event)", @class = "myStyle" }) @Html.ValidationMessageFor(model => model.intWorkersCountInStaffHouses)




and I am calling JavaScript functions in this view as follows

function StaffHouses_Click() {
var radio1 = document.getElementById("rdoSchStaffHousesY");
var radio2 = document.getElementById("charSchoolHaveStaffHouses");
if (radio1.checked == true) {
document.getElementById("intStaffHousesCount").disabled = false;
document.getElementById("intWorkersCountInStaffHouses").disabled = false;
}
else {
document.getElementById("intStaffHousesCount").disabled = true;
document.getElementById("intWorkersCountInStaffHouses").disabled = true;
document.getElementById("intStaffHousesCount").value = "";
document.getElementById("intWorkersCountInStaffHouses").value = "";


('#intStaffHousesCount .input-validation-error').addClass('input-validation-valid');


('#intStaffHousesCount .input-validation-error').removeClass('input-validation-error');


这篇关于清除验证目的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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