473,804 Members | 3,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validation in IE 7 - Issue

7 New Member
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('E rror: - 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 1443
acoder
16,027 Recognized Expert Moderator MVP
Instead of return false, use this.focus().
Feb 9 '08 #2
Saith
7 New Member
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 Recognized Expert Moderator MVP
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 New Member
The onblurr with with this.focus and return true did the trick. thanks!
Feb 11 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
No problem, you're welcome. Glad to hear that you got it working.
Feb 12 '08 #6
Saith
7 New Member
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 Recognized Expert Moderator MVP
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
2780
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 with the last value it had before the user changed it. Pretty typical Now, the user types some invalid value and clicks OK. The user gets a message saying the value is not valid, and the bad value is replaced with the last good one. So far, so...
7
2876
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 can have the validator just disable certain control's postback and other part of page continue their functionality. Thanks,
8
3378
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 is that the error msg doesn't show unit the use hits the submit button or the user enters data and moves the focus to another control so the field becomes dirty. So far so good. Now when the user goes back to that control and starts to input data...
2
4566
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 /aspnet_client/system_web/1_1_4322/WebUIValidation.js but I think I've now fixed this. What is happening now is I'm not getting a security issue but the validation is not occuring, the page submits without validation. When
5
3248
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 I use an argument to difference between an 'edit' vs. and 'add. But since I have field validation on both 'footer' and 'edit' columns I can't submit my edits since the footer validation kicks in.If I take the validation off then the both work fine...
45
4753
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
3954
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 the same issue. However, none of the suggested fixes solved my particular problem. I tracked down the cause of the problem, which is related to aspx page parser's handling of controls inside html comments. The problem may be quite common and well...
3
6340
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 older version that I am updating. Thus I get this message. It tells me only how many records have errors, not which errors or which records. Anyone have a nice solution to identifying the specific records involved? Maybe even the specific...
7
7002
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 is correct I need to submit to another page that uses the form data. I first tried making the form submit action= field point to the same file. When the form was correct, I tried loading the next page by using <META http-equiv refresh>. But...
3
2762
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
10593
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10329
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9163
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.