开发者

Issues disabling/enabling multiple inputs in JQuery

I have a form with an "OR" condition that either dims/disables 3 input fields or 1 input field depending on if there are entries in each.

I'm having a lot of trouble with inconsistent results with this--namely when the user tabs through inputs--and could really use some help.

The code that's problematic is:

$(document).ready(function() {

  $("#firstInitial,#lastName,#memberNo").blur(function() {
      if ($(this).val() != '')
          $("#datepicker").attr("disabled", "disabled").addClass("disabledStyle").val('');            
      else
          $("#datepicker").attr("disabled", "").removeClass("disabledStyle");

  });

});

I'm trying to dim/disable a datepicker field when there's an entry in either firstInitial, lastName, or member开发者_如何学GoNo, or any combination of those three--and undisable datepicker if entries are removed in these. What's happening is tabbing through these breaks everything and causes inconsistent results.

Is there another technique I could try?

Thanks.


I'm not sure I understood all of your question, but if you name your html elements using class="someName" instead of id="someName", then you have access to the "." JQuery syntax.

$(".someClass").someMethod() will apply the method to all elements declaring this class in their attributes.

I'm not certain if it's atomic though...


If you're seeing problems in FireFox, the following may be helpful. (hint: set autocomplete=off) Bug With Firefox - Disabled Attribute of Input Not Resetting When Refreshing

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜