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.

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.