By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,445 Members | 1,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,445 IT Pros & Developers. It's quick & easy.

Another IE7 - Onchange Events

P: 7
I need to define a text box that accepts a string input. If the user enters a value thats invalid I want to display a warning but prevent him from taking focus away from that box unless he corrects the data input.

For example:
<input name="Textbox1" value="Hello World One" onchange="if (this.value == 'bug'){alert('Error: - 1'); return false;}"></input>

In this test if i enter 'bug' focus should not leave this field unless i change 'bug' to something else and I should get the alert each time i attempt to.

This input field works fine under IE6 but under firefox or IE 7.

I heard that IE 6 used standards that were not in compliance with W3C...I dont know if this is the reason why i have this problem :(

Hi, I posted this question in the area for JavaScript related questions but I felt maybe someone who focued more on HTML in general would be able to help.
Feb 11 '08 #1
Share this Question
Share on Google+
5 Replies


harshmaul
Expert 100+
P: 490
hi,
Its a semi html question but more for javascript anyway////
try onblur instead of onchange.
Feb 11 '08 #2

P: 7
Thanks, my post is still there...so far I got one response. Apparently no one wants to touch that one lol

onblur didnt work for me. if a onChange even fires when you tab out of a field, I wish there was a way to reset the field so if you tried to tab out again the onChange would fire again. its like the browser remembers it was fired so decides that well since i did it once I dont need to do it again for the same input.
Feb 11 '08 #3

harshmaul
Expert 100+
P: 490
Hi again.
Try writting a function that not only pops up the alert but also... makes the input box in focus aswell. if you have difficulty i'll help you tomorow, but i gotta go or i'm gonna miss my train!!

good luck mate.
Feb 11 '08 #4

P: 7
Thanks harshmaul, i'll try that today and post if I run into issues
Feb 11 '08 #5

drhowarddrfine
Expert 5K+
P: 7,435
Please do not double post. This is not a html/css question.
Thread closed.
Feb 11 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.