1

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 memberNo, 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.

Scott H.
  • 129
  • 1
  • 1
  • 6

2 Answers2

0

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...

Joel
  • 3,427
  • 5
  • 38
  • 60
0

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

Community
  • 1
  • 1
timDunham
  • 3,318
  • 23
  • 24