473,320 Members | 2,000 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.

2 text box validations cause loop trap

I have back to back text boxes used to create university account numbers. I'm
actually creating them with a script so they can create as many account
numbers as they need.

<edited and cut down script>
<input type="text" size="5" name="fund_1" onBlur="checkact(this)">
<input type="text" size="5" name="org_1" onBlur="checkact(this)">"

function checkact(entry){
if (!Is_In_Format( entry.value, "dddddd")){
alert("Format: 123456");
entry.focus();
}
}
It works fine UNLESS...they enter the wrong format in "fund_1" and click
the "org_1" text box. They get an alert message (because "fund_1" is wrong)
and the script moves the focus back to "fund_1" which gives them an alert
message becuse they did not properly fill out "org_1"...well, you see where
I'm going with this.

How do you handle this type of thing?
Jul 20 '05 #1
7 1512
In article <ui***************************@news.ks.uiuc.edu> , abbylee26
@hotmail.com enlightened us with...
It works fine UNLESS...they enter the wrong format in "fund_1" and click
the "org_1" text box. They get an alert message (because "fund_1" is wrong)
and the script moves the focus back to "fund_1" which gives them an alert
message becuse they did not properly fill out "org_1"...well, you see where
I'm going with this.

How do you handle this type of thing?


How do *I* handle it? I only validate on form submission, not on blur,
because I've had numerous problems with onblur (cross-browser).

How might you handle it?
Blanks don't fire blur handlers, then check fields again in the form's
onSubmit (assuming/if blanks aren't allowed).

onBlur="if (this.value&&this.value.length>0) checkact(this)"

--
--
~kaeli~
If a book about failures doesn't sell, is it a success?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2
Lee
Abby Lee said:

I have back to back text boxes used to create university account numbers. I'm
actually creating them with a script so they can create as many account
numbers as they need.

<edited and cut down script>
<input type="text" size="5" name="fund_1" onBlur="checkact(this)">
<input type="text" size="5" name="org_1" onBlur="checkact(this)">"

function checkact(entry){
if (!Is_In_Format( entry.value, "dddddd")){
alert("Format: 123456");
entry.focus();
}
}
It works fine UNLESS...they enter the wrong format in "fund_1" and click
the "org_1" text box. They get an alert message (because "fund_1" is wrong)
and the script moves the focus back to "fund_1" which gives them an alert
message becuse they did not properly fill out "org_1"...well, you see where
I'm going with this.

How do you handle this type of thing?

By never, ever, validating onBlur. Use onChange, instead.

Jul 20 '05 #3
Lee <RE**************@cox.net> writes:
Abby Lee said:

I have back to back text boxes used to create university account numbers.
I'm
actually creating them with a script so they can create as many account
numbers as they need.

<edited and cut down script>
<input type="text" size="5" name="fund_1" onBlur="checkact(this)">
<input type="text" size="5" name="org_1" onBlur="checkact(this)">"

function checkact(entry){
if (!Is_In_Format( entry.value, "dddddd")){
alert("Format: 123456");
entry.focus();
}
}
It works fine UNLESS...they enter the wrong format in "fund_1" and click
the "org_1" text box. They get an alert message (because "fund_1" is
wrong)
and the script moves the focus back to "fund_1" which gives them an alert
message becuse they did not properly fill out "org_1"...well, you see
where
I'm going with this.

How do you handle this type of thing?

By never, ever, validating onBlur. Use onChange, instead.


Funny thing...using the onChange "entry.focus();" no longer works.
Jul 20 '05 #4
kaeli <ti******@NOSPAM.comcast.net> writes:
In article <ui***************************@news.ks.uiuc.edu> , abbylee26
@hotmail.com enlightened us with...
It works fine UNLESS...they enter the wrong format in "fund_1" and click
the "org_1" text box. They get an alert message (because "fund_1" is
wrong)
and the script moves the focus back to "fund_1" which gives them an alert

message becuse they did not properly fill out "org_1"...well, you see
where
I'm going with this.

How do you handle this type of thing?


How do *I* handle it? I only validate on form submission, not on blur,
because I've had numerous problems with onblur (cross-browser).

How might you handle it?
Blanks don't fire blur handlers, then check fields again in the form's
onSubmit (assuming/if blanks aren't allowed).

onBlur="if (this.value&&this.value.length>0) checkact(this)"


I understand what you are saying...however, I must varify they are using a 6
digit number for other parts of the form to work for them before the page is
submited.
Jul 20 '05 #5
In article <ui***************************@news.ks.uiuc.edu> , abbylee26
@hotmail.com enlightened us with...


Funny thing...using the onChange "entry.focus();" no longer works.


It has something to do with the event bubbling - I forget the exact
cause, but it's why I didn't use onChange. :)

Try modifying your function and call to

<input type="text" size="5" name="fund_1" id="fund_1" onBlur="checkact
(this.id)">

function checkact(entry){
if (document.getElementById) {
e = document.getElementById(entry);
if (!Is_In_Format( e.value, "dddddd")){
alert("Format: 123456");
e.focus();
}
}
}

Assumes your clients have DOM browsers, though. Mine had NN4 for the
longest time, and this won't work in that.

--
--
~kaeli~
Synonym: the word you use in place of a word you can't
spell.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #6
kaeli <ti******@NOSPAM.comcast.net> writes:
In article <ui***************************@news.ks.uiuc.edu> , abbylee26
@hotmail.com enlightened us with...


Funny thing...using the onChange "entry.focus();" no longer works.


It has something to do with the event bubbling - I forget the exact
cause, but it's why I didn't use onChange. :)

Try modifying your function and call to

<input type="text" size="5" name="fund_1" id="fund_1" onBlur="checkact
(this.id)">

function checkact(entry){
if (document.getElementById) {
e = document.getElementById(entry);
if (!Is_In_Format( e.value, "dddddd")){
alert("Format: 123456");
e.focus();
}
}
}

Assumes your clients have DOM browsers, though. Mine had NN4 for the
longest time, and this won't work in that.


Thank you.
It's so nice that I'm creating this application for our intranet...everyone
has IE6.
Jul 20 '05 #7
In article <ui***************************@news.ks.uiuc.edu> , abbylee26
@hotmail.com enlightened us with...

Thank you.
It's so nice that I'm creating this application for our intranet...everyone
has IE6.


I know, I love that. :)
We have NN6 and IE6.
It's nice to know everyone has to have certain browsers. I have a lot
more leeway.
Although I test my stuff in Mozilla and Opera 7 too just for kicks
sometimes. I have learned some valuable things doing that. JIC I ever
get a job where it ISN'T intranet. heh

--
--
~kaeli~
Local Area Network in Australia:... the LAN down under.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Christiaan | last post by:
I am trying to create a small javascript to change the button text and then submit it and do all kinds of form validations. So I have a button with the value "Save", when the button is clicked it...
59
by: kk_oop | last post by:
Hi. I wanted to use exceptions to handle error conditions in my code. I think doing that is useful, as it helps to separate "go" paths from error paths. However, a coding guideline has been...
0
by: Rajesh Jain | last post by:
I Have 2 separate schemas. --------------Schema 1 is defined as below----------- <xs:schema targetNamespace="http://Schemas/1" xmlns="http://Schemas/1" xmlns:xs="http://www.w3.org/2001/XMLSchema"...
2
by: Paulo Rodrigues | last post by:
Hi I would like some help about the following : I have a text field and I don't want it contains any numbers. How can I limit this situation ? So far, I couldn't find literature exacly...
1
by: DotNetJunkies User | last post by:
I successfully implemented this poup calendar control in C#. But the problem I am having is that the button click is posting back and the validator is getting fired which is asking all the required...
12
by: Adam J. Schaff | last post by:
I am writing a quick program to edit a binary file that contains file paths (amongst other things). If I look at the files in notepad, they look like: ...
23
by: shank | last post by:
I have the below code found on an ASP site. <% arrName = Split(Request("TextArea"),",") %> <% For i = LBound(arrName) To UBound(arrName) Response.Write "ID: " & arrName(i) & "<br>" Next %>
102
by: tom fredriksen | last post by:
Hi I was doing a simple test of the speed of a "maths" operation and when I tested it I found that removing the loop that initialises the data array for the operation caused the whole program to...
7
by: PrateekArora | last post by:
Hi guys... I am using a text box in vb6 application and I have applied validations on it such that it will only accept Numeric data through keyboard. But the problem is when I try to paste some...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: 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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.