Hi guys,
I have this piece of javascript which is supposed to validate on the clientside. I created it using this tutorial: http://www.php-mysql-tutorial.com/wikis/php-tutorial/form-validation-using-php.aspx
Unfortunately I'm getting this warning: "There is a syntax error on line 48. Code hinting may not work until you fix this error".
My code is 110 lines long, so I didn't want to post it here so I ran this code through http://www.jslint.com/, and this is what that told me: "Problem at line 4 character 5: Expected an identifier and instead saw 'with'."
I'm still fairly lost, so here is a snippet from the start of the code of the code:
function checkForm()
{
var vcompName, vadd1, vadd2, vcountry, vcontact1, vtelephone1, vemail, vsiteurl;
with(window.document.form1)
{
vcompName = compName;
vadd1 = add;
vadd2 = add2;
vcountry = country;
vcontact1 = name;
vtelephone1 = tel;
vemail = email1;
vpackage = package;
vsiteurl = url;
}
if(trim(vcompName.value)=='')
{
alert('Please enter the company name');
vcompName.focus();
return false;
}
else if(trim(vadd1.value)=='')
{
alert('Please enter your address')
vadd1.focus();
return false;
}
}
You can see how it goes... Here is the trim function
function trim(str)
{
return str.replace(/^\s+|\s+$/g,'');
}