0

I'm validating the form input for example say First Name on click of a button.If empty i change the class to

    .ValidateError
{
    border: 3px solid #ff9600;
    background: #ffebe9;
    padding: 4px 4px 5px 4px;
    color: #404040;
}

On focus on the text box i'm trying to remove this class from the input box using the following script on document.ready

  $('#divPersonalInfo input').focusin(function () {
        $(this).removeClass().addClass('input w220');
    });
});

Here is the html code

    <div id="divPersonalInfo" class="PersonalInfo">

  <h2 id="hPersonal">
    Personal Information
  </h2>

  <div class="FormColumn FloatLeft">
    <label>
      first name*
    </label>
    <br />
    <input maxlength="100" id="txtFirstName" placeholder="First Name" class="input w220 "/>
  </div>

  <div class="FormColumn FloatLeft">
    <label>
      last name*
    </label>
    <br />
    <input maxlength="100" id="txtLastName" placeholder="Last Name" class="input w220"/>
  </div>

  <div class="FormColumn FloatLeft">
    <label>
      email*
    </label>
    <br />
    <input maxlength="100" id="txtPersonalEmailId" placeholder="will be seen when sending your web profile/app to your colleagues" class="input w220"/>
  </div>
</div>

But the class isn't removed on focusin

4

1 回答 1

2

如果你只想删除“ValidateError”,你应该写一个类名

$(this).removeClass("ValidateError");

顺便提一句。使用 jquery 你可以像这样使用你的焦点

$(selector).focus(function) 
于 2013-08-13T10:43:52.100 回答