473,397 Members | 2,077 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,397 software developers and data experts.

double alert onBlur

Hi,
I'm trying to find a work-around for a javascript issue i have.
i have a list of text input fields (created using asp) and onblur, i loop through all fields evaluating each one, making sure it contains only numbers, and place focus back on the incorrect field if the evaluation fails (and show an alert box).
the problem is, i evaluate as i leave a field (A) and enter the next (B), and so if the evaluation fails, my function is called for a second time (when my code leaves the B fields) and fails again, so the alert box is called 2 in short succession.
of course if i dont put focus on field A when it fails, i wouldnt had a problem but i'd prefer to show the user exactly where the error is.
any help appreciated....
Vauneen
Sep 14 '06 #1
1 1913
hi vauneen

I remember i had to go through a similar situation in my good old days.

I think what I did may be of some help to you

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/javascript">
  2.  
  3. var error1,error2,error3;
  4.         if(document.bloody_thing_1.value == "") {
  5.             error1 = "Enter a valid bloody_thing_1.\n";
  6.         } 
  7.         if(document.bloody_thing_2.value == "") {
  8.             error2 ="Enter a valid bloody_thing_2.\n";
  9.         } 
  10.         if(document.bloody_thing_3.value == "") {
  11.             error3 = "Enter a valid bloody_thing_3.\n";
  12.         } 
  13.     var error = "";
  14.     if(error1 != null) {
  15.         error = error + error1;
  16.         document.bloody_thing_1.value="";
  17.         document.bloody_thing_1.focus();
  18.     }
  19.     if(error2 != null) {
  20.         error = error + error2;
  21.         document.bloody_thing_2.value="";
  22.         document.bloody_thing_2.focus();
  23.     }
  24.     if(error3 != null) {
  25.         error = error + error3;
  26.         document.bloody_thing_3.value="";
  27.         document.bloody_thing_3.focus();
  28.     }
  29.     if(error != "") {
  30.         document.moneyform.total_monthly_income.value="";
  31.         alert("Following cool and sexy errors occured in your form submission. \n"+error);
  32.         return false;    
  33.     }
  34.     else {
  35.         return true;
  36.     }    
  37.  
  38.  
  39. </script>
Please change the varible names and error messages as per your need

Also willing to help more if needed.


-Ramesh
Nov 2 '06 #2

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

Similar topics

1
by: Display Name | last post by:
the customer I'm developing a site for uses a canned form-parsing page that allows her to have an email subscription opt-in page add emails to a list she can manage using a link that you point your...
5
by: Martin | last post by:
I have the following function in the onchange event of several text boxes. If the user enters an invalid number the alert displays. I would like to return the user to that same field after he...
2
by: cschang | last post by:
I have a form containing a link next to an input box. I include a javascript function in the input by using the onblur='fuc()'. I used this function to open another ASP page to do something and...
1
by: neil S via DotNetMonster.com | last post by:
I have a custom control with a textbox and dropdown list. The dropdown list is hidden and acts as a data source for the textbox. When the user enters text in the textbox, an onKeyup event is...
4
by: Gregc. | last post by:
Hi Would someone have a basic example of form validation that validates name and address, but using only one alert box that displays which fields haven't been completed? I can do it on an...
11
by: prakashsurya | last post by:
Helo i am going through the validations of date of birth in form which consists of three combo boxes dd/mm/yyyy. My aim is to use onblur function through which i hav to call a function. And the...
4
by: PJ6 | last post by:
Is there a way to prevent the double-click event on an element from causing IE6 to select everything? Cancelling the event doesn't work. Paul
2
dlite922
by: dlite922 | last post by:
Hey guys, this is so weird, i don't know what else to do. Hopefully one of you is a Smarty guru as this is difficult to search (google and smarty forum) and if you aren't i'll post answer here, i'm...
4
by: rubenhan | last post by:
Hey, guys. My basic idea is this. When I write "1" in the pre-existing text field and onblur, I want to add a new field with a set of attributes, which turned out to be the same as the pre...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.