Hello. I created a form using JS validation with the form tag as
What values does pvg_sub() return ?
If you want the form to submit it should return true.
Tim
Thanks for responding. All the subs return true unless previously set to
false, I think. The external js form validation code is below. I got
this script off a website too:
***********************************************
<!--
var b = 0 ;
var i = 0 ;
var errmsg = "" ;
var punct = "" ;
var min = 0 ;
var max = 0 ;
function pvg_email(field) {
if (b && (field.value.length == 0)) return true ;
if (! emailCheck(field.value))
{
field.focus();
if (field.type == "text") field.select();
return false ;
}
return true ;
}
function pvg_filledin(field) {
if (b && (field.value.length == 0)) return true;
if (field.value.length < min) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false ;
}
if ((max > 0) && (field.value.length > max)) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false ;
}
return true ;
}
function pvg_number(field) {
if (b && (field.value.length == 0)) return true ; ;
if (i)
var valid = "0123456789"
else
var valid = ".,0123456789"
var pass = 1;
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") pass = 0;
}
if (!pass) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
}
if (field.value < min) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
}
if ((max > 0) && (field.value > max)) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
}
return true ;
}
function pvg_numseq(field) {
if (b && (field.value.length == 0)) return true ;
var valid = punct + "0123456789"
var pass = 1;
var digits = 0
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") pass = 0;
if (valid.indexOf(temp) > (punct.length-1) ) digits++ ;
}
if (!pass) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false ; ;
}
if (digits < min) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
}
if ((max > 0) && (digits > max)) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
}
return true ;
}
function emailCheck (emailStr) {
var checkTLD=1;
var
knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|ws)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert(errmsg);
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert(errmsg);
return false;
}
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert(errmsg);
return false;
}
}
if (user.match(userPat)==null) {
alert(errmsg);
return false;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr
.search(atomPat)==-1) {
alert(errmsg);
return false;
}
}
if (checkTLD && domArr[domArr.length-1].length!=2 &&
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert(errmsg);
return false;
}
if (len<2) {
alert(errmsg);
return false;
}
return true;
}
function pvg_sub()
{
b=0;
errmsg="Invalid email address";
if (! pvg_email(document.form1.r_Email) ) return false ;
b=0;
errmsg="First name must be filled in.";
min=2;
max=60;
if (! pvg_filledin(document.form1.r_Firstname) ) return false ;
b=0;
errmsg="Last name must be filled in.";
min=2;
max=60;
if (! pvg_filledin(document.form1.r_Lastname) ) return false ;
}
// -->