?
Solved

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

Posted on 2004-11-11
12
Medium Priority
?
1,605 Views
Last Modified: 2010-08-05
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
0
Comment
Question by:aviponugoti
  • 5
  • 4
  • 3
12 Comments
 
LVL 33

Assisted Solution

by:knightEknight
knightEknight earned 300 total points
ID: 12556493
just before the calendar closes, do this:

document.formName.textBoxName.onchange();
0
 
LVL 15

Expert Comment

by:justinbillig
ID: 12556494
You have to manuall call the on change event

formname.textboxname.onchange( );

0
 
LVL 15

Expert Comment

by:justinbillig
ID: 12556498
doh
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 33

Expert Comment

by:knightEknight
ID: 12556502
great minds think alike!  (and so do ours:)
0
 

Author Comment

by:aviponugoti
ID: 12556888
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
0
 
LVL 15

Expert Comment

by:justinbillig
ID: 12556969
do you have a button that opens the calender up?

<input type="button" onclick="FunctionThatOpensYourCalender( );formname.textboxname.onchange( );">
0
 

Author Comment

by:aviponugoti
ID: 12557296
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
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 12557312
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?
0
 

Author Comment

by:aviponugoti
ID: 12557349
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

0
 
LVL 15

Accepted Solution

by:
justinbillig earned 375 total points
ID: 12557972
Ok from what your getting at I can assume that the window that opens up the calender isn't modal. So the only way your going to have to get around this is a function on timeout

var g_intTimer
function ToggleButton( )
{
     formname.buttonname.disabled = FunctionThatValidatesTheDateInTheTextBox( );

    // Recall this function
    g_intTimer = setTimeout( "ToggleButton", 3000 );
}
0
 

Author Comment

by:aviponugoti
ID: 12562216
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
0
 

Author Comment

by:aviponugoti
ID: 12562226
On second thought i am splitting the points just for trying to help.
Thanks.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question