Problem with Java Script Validation

springmedia

New Member
Hi there guys, I have just inherited a new client who has a site developed with a javascript validation on the enquiry form.

I'm not too familiar with this and need to amend the the bold, eg emailz with an email reg expression.

and the phonez to only validate on numbers only.

This client is currently getting spammed heavily and we can't use captcha, just yet.

If there is anyone that can help I would be much appreciative.

Thanks again,

Rich.

function validate(){

var strFieldName, objFieldName;
var strNameValue, strPhoneValue, strEmailValue
var strNotesValue, strPostcode

strFieldName = "document.quickform.namez";
objFieldName = eval(strFieldName);
strNameValue = objFieldName.value;

if (strNameValue =="") {
alert("Please enter your name to send this enquiry.");
return false;
}

strFieldName = "document.quickform.emailz";
objFieldName = eval(strFieldName);
strEmailValue= objFieldName.value;

if (strEmailValue=="") {
alert("Please enter your email to send this enquiry.");
return false;
}


strFieldName = "document.quickform.phonez";
objFieldName = eval(strFieldName);
strPhoneValue= objFieldName.value;

if (strPhoneValue=="") {
alert("Please enter your contact phone number to send this enquiry.");
return false;
}


strFieldName = "document.quickform.detailsz";
objFieldName = eval(strFieldName);
strNotesValue= objFieldName.value;

if (strNotesValue=="") {
alert("Please tell us some details of your accident to send this enquiry.");
return false;
}

strFieldName = "document.quickform.postcodez";
objFieldName = eval(strFieldName);
strPostcode= objFieldName.value;

if (strPostcode=="") {
alert("Please enter your postcode to send this enquiry.");
return false;
}
else {
if (checkPostCode (strPostcode)) {
var iCheck = 1;
}
else {
alert ("Postcode has invalid format");
return false;
}
}
}
 

springmedia

New Member
Thanks for your help guys, I think I have a work around see below if interested. Cheers loroy30 for the link I'll check that out for future projects.

Have a good days guys.

strFieldName = "document.quickform.phonez";
objFieldName = eval(strFieldName);
strPhoneValue= objFieldName.value;

if (strPhoneValue=="") {
alert("Please enter your contact phone number to send this enquiry.");
return false;
}
if (isNaN(strPhoneValue)) {
alert("Please enter the phone number as a Number.");
return false;
}
 
Top