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.

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.