0

Am using the below code to change the class at runtime in Jquery FocusOut

$("#txtNewAttributes").focusout(function () {
    var attributeTextBox = $("#txtNewAttributes").val()
    if ($.trim(attributeTextBox) == "Height")
        $(txtNewValues).removeClass('alphaonly').addClass('numbersonly');
    if ($.trim(attributeTextBox) == "string" || $.trim(attributeTextBox) == "string2")
        $(txtNewValues).removeClass('numbersonly').addClass('alphaonly');
});

And am having validation using the class names loaded in the page.

My issue is in FireBug I see the Class name has changed for the txtNewValues , But still the expected validations(alphaonly,numbersonly) are not fired.

Am I missing something here?

oz123
  • 27,559
  • 27
  • 125
  • 187
user2067567
  • 3,695
  • 15
  • 49
  • 77

1 Answers1

0

probably the numeric only and alpha only validations get fired on focusout event only. As you are assigning classes on the same event, it could be the reason that the order of the execution is causing this issue. Please check that first.

If this is the case then you may get help from the following post.

Event Ordering

Community
  • 1
  • 1
K D
  • 5,889
  • 1
  • 23
  • 35