473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Validation in IE 7 - Issue

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 :(
Feb 8 '08 #1
7 1425
acoder
16,027 Expert Mod 8TB
Instead of return false, use this.focus().
Feb 9 '08 #2
Saith
7
Thanks for the response, but this does not work for me. I've using a bunch of stuff to get focus back to the input box that generated the error but even when focus is returned the user can Tab out without gettign the error message again :(
Feb 11 '08 #3
acoder
16,027 Expert Mod 8TB
Thanks for the response, but this does not work for me. I've using a bunch of stuff to get focus back to the input box that generated the error but even when focus is returned the user can Tab out without gettign the error message again :(
That's because onchange is fired when the input changes, not when you blur. Use onblur, but alerts onblur are not advisable. Use some visible notification, e.g. red border and an error message next to the field instead.
Feb 11 '08 #4
Saith
7
The onblurr with with this.focus and return true did the trick. thanks!
Feb 11 '08 #5
acoder
16,027 Expert Mod 8TB
No problem, you're welcome. Glad to hear that you got it working.
Feb 12 '08 #6
Saith
7
Hello again, something else just came to mind...Why is it not appropriate to use an alert in a onBlur event handler?
Feb 12 '08 #7
acoder
16,027 Expert Mod 8TB
Hello again, something else just came to mind...Why is it not appropriate to use an alert in a onBlur event handler?
See this link (How it works).
Feb 12 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Marina | last post by:
Imagine a form with some fields and an OK buttons that saves the information. Each field has validation logic in the Validating event. If the input is not valid, the control's value is replaced...
7
by: A.M | last post by:
Hi, I have a validation control in my page that upon any invalid data, it disables all buttons in the page. basicly i don't have any postback in the page if the validator finds any error. How...
8
by: moondaddy | last post by:
I have a form for entering a user's address and all fields have a required validating control associated with them and the error msg for each field displays right next to it. The normal behavior...
2
by: Mark | last post by:
Hi, I've been having problems with the validation controls not working on my deployment server. Initially it was a security issue with the anonymous account not having permissions to access...
5
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and...
45
by: Pat | last post by:
its seems asp.net validation doesn't fire when using FireFox? Tested a page and it doesn't fire. It seems the javascript doesn't fire Any ideas?
1
by: Hong Hao | last post by:
Recently, I was trying to modify an existing aspx page when client-side validation on that page stopped working. I searched this group and the web in general and found that other people have had...
3
by: Bob Alston | last post by:
I have a routine to copy data to new versions of my app via insert into sql statements. Unfortunately, due to evolution of my app, sometimes the new version has more restrictive editing than an...
7
by: h7qvnk7q001 | last post by:
I'm trying to implement a simple server-side form validation (No Javascript). If the user submits a form with errors, I want to redisplay the same form with the errors highlighted. Once the form...
3
by: teo | last post by:
Mozilla error on postback and validation ----------- A Button causes a Listbox to desappear. If no item has been selected on the Listbox, all is OK. If one or more items are selected,
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.