|
-----Original Message-----
From: Tom Deskevich [mailto:thomas.l.deskevich@xxxxxxxxxxxxx]
Sent: Monday, November 23, 2009 8:21 AM
To: 'WEB400-request@xxxxxxxxxxxx'
Subject: JavaScript sticks on focus.
I have a validation function and the this is the last thing it does.
var mytext=document.getElementById("sizip")
if(check5(mytext,"Zip Code must be 5 digits.")==false)
{mytext.focus();return false;}
==== Function check5
function check5(mytext,alerttxt){
var re5digit=/^\d{5}$/ //regular expression defining a 5 digit number
if (mytext.value.search(re5digit)==-1) //if match failed
alert(alerttxt);return false;
=====
It will validate ok, if I do not have 5 digits, I get an error box.
But then if I click the accept button again, it puts focus back on my zip
code with no error.
I scanned through the file and do not find any other places where I am
doing focus on this.
The only other places I reference it is where it is defined and where I
tell it to auto jump
to the next text box.
<input type="text" name="sizip" size="5" tabindex="10" maxlength="5">
autojump('sizip', 'sizip4', 5);
function autojump(fieldName,nextFieldName,fakeMaxLength)
{
var myForm=document.forms[document.forms.length - 1];
var myField=myForm.elements[fieldName];
myField.nextField=myForm.elements[nextFieldName];
if (myField.maxLength == null)
myField.maxLength=fakeMaxLength;
myField.onkeydown=autojump_keyDown;
myField.onkeyup=autojump_keyUp;
}
I AM THANKFUL FOR THIS FORUM. (The priest at confession Saturday told me
to remember things this week I am thankful for)
Tom Deskevich
Infocon Corporation
Phone 814-472-6066
Fax 814-472-5019
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.