Hi there,
I've got this code:
and I'd like to add a focus() or select() to the formfield that was just validate if the vlaue was invalid.
I'm just starting to work with CheckBanknr(this), my first script where I use "(this)". Usually I create of someting like: document.forms['betalen']elements['reknr1'].focus() but I'd like to focus with that "this"
Just changing
to
did not work.... What is the right way to do this??
T.I.A.
Don't eat yellow snow!
I've got this code:
Code:
<script language="JavaScript">
<!--
function CheckBanknr(val) {
if ("".replace)
{
waarde = val.value;
var rekNr = String(waarde).toUpperCase().replace(/[\s\t-\.]/g,""); // Delete white space, hyphens en periods
if (rekNr.match(/[^P^0-9]/g))
{
// If anything left is not a digit or a P then it's not an rekeningnr
alert ('The rekeningnummer is not valid!!!');
return false;
}
}
}
//-->
</script>
<body>
<form method=post action="" name="betalen">
<input type="text" name="rek_nr1" onChange="return(CheckBanknr(this))" size=9 maxlength=9>
<input type="text" name="rek_nr2" onChange="return(CheckBanknr(this))"size=9 maxlength=9>
<input type="text" name="rek_nr3" onChange="return(CheckBanknr(this))"size=9 maxlength=9>
</form>
</body>
and I'd like to add a focus() or select() to the formfield that was just validate if the vlaue was invalid.
I'm just starting to work with CheckBanknr(this), my first script where I use "(this)". Usually I create of someting like: document.forms['betalen']elements['reknr1'].focus() but I'd like to focus with that "this"
Just changing
Code:
if (rekNr.match(/[^P^0-9]/g))
{
// If anything left is not a digit or a P then it's not an rekeningnr
alert ('The rekeningnummer is not valid!!!');
return false;
}
Code:
if (rekNr.match(/[^P^0-9]/g))
{
// If anything left is not a digit or a P then it's not an rekeningnr
alert ('The rekeningnummer is not valid!!!');
this.focus();
return false;
}
T.I.A.
Don't eat yellow snow!