J
Jessica.Sexton
So now I have to create a regular expression using javascript, this is
what I have so far:
<script>
function numbersOnly(e){
var redigits=/(^-?\d\d*$)/; //regular expression defining numbers
if (document.form1.firstInput.value.search(redigits)==-1) //if match
failed
if (document.form1.secondInput.value.search(redigits)==-1)
return false //disable key press
}
</script>
-----------------------------------------------------------------------------------------------------------------
And then for the input I have:
<input onkeypress="return numbersonly(event)" type="text"
name="firstInput">
However it doesn't work, so what am I doing wrong? Also is there a
more efficient way to do the if statements without having to list
"firstInput.value" and then "secondInput.value" on the next
line?
Thanking you in advance,
Jessica
what I have so far:
<script>
function numbersOnly(e){
var redigits=/(^-?\d\d*$)/; //regular expression defining numbers
if (document.form1.firstInput.value.search(redigits)==-1) //if match
failed
if (document.form1.secondInput.value.search(redigits)==-1)
return false //disable key press
}
</script>
-----------------------------------------------------------------------------------------------------------------
And then for the input I have:
<input onkeypress="return numbersonly(event)" type="text"
name="firstInput">
However it doesn't work, so what am I doing wrong? Also is there a
more efficient way to do the if statements without having to list
"firstInput.value" and then "secondInput.value" on the next
line?
Thanking you in advance,
Jessica