Hi friends ...............,<br> I have a problem where my onchange event is not firing at all. I have tried using both Firefox 1.5.0.7 and IE 6.0.2900.<br><br> This is my code to verify that a text field has not been left blank:<br> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head><title>Check if the text field is empty</title> <meta http-equiv="Content-Type" content="text/html"; charset="EN-US";> <style type="text/css"> </style> <script type="text/javascript"> <!-- script hiding starts function checkTextField(field) { alert("entered function: checkTextField."); if ( isEmpty(field.value) ) { alert("Field is empty"); } else { alert("Field is not empty and the value entered is: " + field.value + "."); } } //General Function to check if the text field is empty. function isEmpty(inputStr) { if ( inputStr == "" ) { return true; } else { return false; } } // script hiding ends --> </script> </head> <body> <form onsubmit="return false"> Enter/Not-enter something to check whether the field is empty: <input type="text" name="checking" id="checking" value="" onchange="checkTextField(this)" /> <input type="text" name="nothing" id="nothing" /> </form> </body> </html> <!-- PROBLEM 1.To validate if a text field is filled – when I tab out of that text field without entering any value, it does not fire the function. But when I fill in something and then tab out, it fires the function. And then immediately after this if I go back to that same field and delete everything and then tab out, then the function fires and tells me that there is no data in the field. Then immediately after this if I again go to that field and tab out, then the function does not fire. Its like this – the onchange event fires when data is entered, or when data is entered and for 1 time after that without data too. --> Thanks in advance. Cheers. vivek. .................
Thank You evoleto. The solution was so simple, can't believe it. The javascript bible that I was reading has so casually given onchange as the thing to be used, and they were worng!