cjkenworthy
Programmer
I'm trying to raise an error message if an input value does not begin with '09' or '08' using the following code:
var contains1 = document.frmNGN.txtNGN.value.match(/\b08/);
var contains2 = document.frmNGN.txtNGN.value.match(/\b09/);
if (!contains1 || !contains2) {
alert("A Non Geographic Number (NGN) must begin 08 or 09"
;
return false;
}
This doesn't appear to work because it raises the error regardless of what data is put in! It seems to work if I only use !contains1 in the condition - but i need both in.
Any help?
var contains1 = document.frmNGN.txtNGN.value.match(/\b08/);
var contains2 = document.frmNGN.txtNGN.value.match(/\b09/);
if (!contains1 || !contains2) {
alert("A Non Geographic Number (NGN) must begin 08 or 09"
return false;
}
This doesn't appear to work because it raises the error regardless of what data is put in! It seems to work if I only use !contains1 in the condition - but i need both in.
Any help?