Link to home
Start Free TrialLog in
Avatar of aviponugoti
aviponugoti

asked on

How to trigger the onChange/OnBlur event when value changed in a text box from background JavaScript function

Hi,
   I have a text box which takes a date value and i have a icon by the side of the box which performs the JS calender functionality.I have a button which i am supposed to enable when valid date is entered.

when a user enters valid date manually the button is getting enabled. but when the user uses the calender functionality to get the date in the text field the OnChange is not being triggered so the button is not being enabled. Can some one suggest a way by which i can make this work.

How to trigger the onChange/OnBlur event when value changed in a text box from background JavaScript function.

Thanks in advance.

-Avinash
SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of justinbillig
justinbillig

You have to manuall call the on change event

formname.textboxname.onchange( );

great minds think alike!  (and so do ours:)
Avatar of aviponugoti

ASKER

THanks for the reply. The calender is a global thing which is beinging used all over the application. I can not change any code related to that.
I will i  know that the calender fucntionality is done for me to explicitly call the onChange() event.

Looking for ur reply.
-Avinash
do you have a button that opens the calender up?

<input type="button" onclick="FunctionThatOpensYourCalender( );formname.textboxname.onchange( );">
I have a button that opens the calender i already tried what u suggested.

The calender only opens when the function is called it does not insert a value in to the textbox. I want the onChange to be called after the value is inserted by the calender function.

Thanks
Avinash
that is why you will need to do it when the calendar closes -- or when the calendar changes the date field.
You say you can't change the calendar code ... can you look at it and see what it is doing?
When i say i can not change it i mean i am not supposed to change it the same function is being used at a lot of other places. I am looking for a work around.

Thanks
Avinash

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello guys,
     I think what justinbillig  suggested should work. But i already change my approch i made my button enable and onClick i am validating date inthe text field and depending upon the result the button performs its action. I am giving the points to justinbillig for giving a resonable answer.

Thanks
Avinash
On second thought i am splitting the points just for trying to help.
Thanks.