Hi,
I’m new to Javascript so I apologise if this is an obvious query..!
I’m trying to incorporate a RegExp validation into the existing validate function but when a string that matches (I hope) re1 e.g. AB12 12AB is entered I still get the format alert and the form won’t submit.
Any ideas would be very gratefuly received!
[code=php]function validate(node, alerttxt, re) {
with (node)
if (value == null || value == “”) {
alert(alerttxt); return false;
}
else if (re.test(node) ==false) {
alert(alerttxt+ ” format”); return false;
}
}
var re1 = /^D{1,2}d{1,2}s?d{1,2}D{1,2}$/;
var re2 = /^Dw{4}s?w{5}s?w{3}d[!|&|@|?]$/;
function validate_form(thisform) {
with (thisform) {
if (validate(Node1, “Please check Node1 field”, re1) == false)
{ Node1.focus(); return false; }
if (validate(Node2, “Please check Node2 number”,re2) == false)
{ Node2.focus(); return false; }
else {
return true;
}
}
}
…
<form method=”post” onsubmit=”return validate_form(this)” action=”http://…decode_form.cfm”>[/code]