如何清除文本框的验证符号以单击单选按钮事件 [英] How to Clear Validation Symbol for Textbox for radio button click Event

查看:90
本文介绍了如何清除文本框的验证符号以单击单选按钮事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我点击是单选按钮文本框应该启用,当我点击保存按钮时,它显示验证对于文本框。

我的问题是,当我正在打开否单选按钮时它会禁用文本框但是验证符号没有在mvc4中清除

这是我的观点

Hi,
When i am clicking "Yes" Radio Button Text Box Should be Enabled and when I''m clicking on Save Button it''s showing Validation for text Box .
My Problem is when I''m clocking on "No" Radio Button it''s disabling the text box but validation Symbol is not clearing in mvc4
this is my view

 <td>Solar Panels</td>
                   <td>

                       @Html.RadioButton("rdoSolar_Panels", 1, new { name = "rdoSolarPanels", id = "rdoSolarPanelsY", onclick = "rdoSolarPanels1_Click()", tabindex = "8" })Yes
                 @Html.RadioButton("rdoSolar_Panels", 2, new { name = "rdoSolarPanels", id = "rdoSolarPanelsN", onclick = "rdoSolarPanels1_Click()", tabindex = "9" })No
              @Html.ValidationMessageFor(model => model.rdoSolar_Panels)
                   </td>

<td>If Yes,Count</td>
                   <td>

                           @Html.HiddenFor(model => model.intFacilityID, new { @Value = "6" })

                           @Html.TextBoxFor(model => model.intSolar_panelsCount, new { maxlength = 4, onkeypress = "return validate(event)", @class = "myclass", tabindex = 10, id = "txtYes", disabled = "disabled" })
                          @Html.ValidationMessageFor(model => model.intSolar_panelsCount)



                   </td>



这是java脚本代码




this is java script code

function rdoSolarPanels1_Click() {
    if (document.getElementById("rdoSolarPanelsY").checked == true)
        $("#txtYes").attr("disabled", false);
    else if (document.getElementById("rdoSolarPanelsN").checked == true) {
        if(document.getElementById("txtYes").value=="")     
        {
              $("#txtYes.input-validation-error").addClass('input-validation-valid');
              $("#txtYes.input-validation-error").removeClass('input-validation-error');
             
          }
       
        $("#txtYes").attr("disabled", true);
        $("#txtYes").val(" ");

    }

}

推荐答案

#txtYes)。attr( disabled false );
else if document .getElementById( rdoSolarPanelsN)。checked == true ){
if document .getElementById( txtYes)。value ==
{
("#txtYes").attr("disabled", false); else if (document.getElementById("rdoSolarPanelsN").checked == true) { if(document.getElementById("txtYes").value=="") {


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


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

}
("#txtYes.input-validation-error").removeClass('input-validation-error'); }


这篇关于如何清除文本框的验证符号以单击单选按钮事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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