0

I have a validation function and the this is the last thing it does.

[code = var mytext=document.getElementById("sizip")
if(check5(mytext,"Zip Code must be 5 digits.")==false)
{mytext.focus();return false;}

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.

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by fellathedog
0

Bad dog if you did not!

Fellathedog figured it out himself.

I needed to do an else in my function check5 and return true.

It was always returning false, hence, putting focus on, even when there was NOT an error condition.

GOOD DOG. FELLATHEDOG....

Hopefully, like a dog, the repetition will teach me...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.