Jump to content

Returning focus to a data element on an entry form that does not pass validation.


DouglasMcKibbin

Recommended Posts

Having trouble returning focus to a data element on an entry firm that does not pass validation criteria in Safari and Firefox. Instead the focus goes to the very next data element on the form. For example ….

 

function CheckSS(strng,x)

{

if (strng == "")

{

alert("You didn't enter a Social Security Number.");

HighlightRed(x);

return;

}

else

{

if ((strng.length < 9) || (strng.length > 9))

{

alert("The Social Security Number is the wrong length. Just use numbers, no dashes... like 123456789 not " + strng);

HighlightRed(x);

return;

}

else

{

var illegalChars = /W#/;

if (illegalChars.test(strng))

{

alert( "The Social Security Number contains illegal characters. Just use numbers, no dashes.");

HighlightRed(x);

return;

}

}

}

HighlightWhite(x)

}

Called from …..

SS#: <INPUT name="personal_SS" id="personal_SS" type="text" size=12 value="#########" onblur="CheckSS(this.value,this.id)" onfocus="DoClear(this,this.id)" tabindex=5>

I'm sure I must have done something wrong … any ideas?

Thanks Douglas McKibbin

 

Link to comment
Share on other sites

Thanks,

I tried to no avail …..

 

 

function CheckSS(strng,x)
{
if (strng == "")
{
alert("You didn't enter a Social Security Number.");
HighlightRed(x);
document.getElementById("x").focus();
document.getElementById("x").scrollIntoView();return;
}
else
{
if ((strng.length < 9) || (strng.length > 9))
{
alert("The Social Security Number is the wrong length. Just use numbers, no dashes... like 123456789 not " + strng);
HighlightRed(x);
document.getElementById("x").focus();
document.getElementById("x").scrollIntoView();return;
}
else
{
var illegalChars = /W#/;
if (illegalChars.test(strng))
{
alert( "The Social Security Number contains illegal characters. Just use numbers, no dashes.");
HighlightRed(x);
document.getElementById("x").focus();
document.getElementById("x").scrollIntoView();return; }
}
HighlightWhite(x)
}
and the same thing happens. I know this must just be semantics, but I'm a bit lost.
Thanks so much,
Douglas McKibbin
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...