E
eyoung
I have a function to check a string to make sure it is 6 digites using
the trigger onBlur="CkFrmt(this)"
Problem is I've got 4 fields in a row...if I enter a wrong number in
the first and hit tab I get the error message and my script tries to
move the focus to the first item...but because I hit the tab the focus
in already on the second item which does not contain a 6 digit value so
I must kill the page. help!
function CkFrmt(str)
{
if ( !Is_In_Format( str.value, "dddddd" ))
{
alert("You must enter a 6 digit number");
str.focus();
str.value="";
}
}
function Is_In_Format( str, format )
{
for ( var i = 0; i < format.length; i++ )
{
if ( format.charAt( i ) == "d" )
if ( !Is_Digit( str.charAt( i ) ) )
return false;
}
return true;
}
function Is_Digit( chr )
{
if ( ( chr < "0" ) || ( chr > "9" ) )
return false;
return true;
}
</script>
the trigger onBlur="CkFrmt(this)"
Problem is I've got 4 fields in a row...if I enter a wrong number in
the first and hit tab I get the error message and my script tries to
move the focus to the first item...but because I hit the tab the focus
in already on the second item which does not contain a 6 digit value so
I must kill the page. help!
function CkFrmt(str)
{
if ( !Is_In_Format( str.value, "dddddd" ))
{
alert("You must enter a 6 digit number");
str.focus();
str.value="";
}
}
function Is_In_Format( str, format )
{
for ( var i = 0; i < format.length; i++ )
{
if ( format.charAt( i ) == "d" )
if ( !Is_Digit( str.charAt( i ) ) )
return false;
}
return true;
}
function Is_Digit( chr )
{
if ( ( chr < "0" ) || ( chr > "9" ) )
return false;
return true;
}
</script>