Guest_imported
New member
- Jan 1, 1970
- 0
Hi,
I'm new with javascript just for the mentioning. Anyway, I made a custom code, but can't figure out why the form continues to submit even when the argument is FALSE. I've just about had it with this onSubmit stuff. P.S. if you could copy the code and reply it with corrections, it would be helpful.
Thanks, here is the new custom script:
I'm new with javascript just for the mentioning. Anyway, I made a custom code, but can't figure out why the form continues to submit even when the argument is FALSE. I've just about had it with this onSubmit stuff. P.S. if you could copy the code and reply it with corrections, it would be helpful.
Thanks, here is the new custom script:
Code:
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
function runAll() {
emailCheck(document.info.email.value);
}
function emailCheck (emailStr) {
var checkTLD=0;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
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("The Email Address Is Invalid");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("The Username Contains Invalid Characters.");
return false;
}
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths Domain Name Contains Invalid Characters.");
return false;
}
}
if (user.match(userPat)==null) {
alert("The Username Is Invalid.");
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("The Destination IP Address Is Invalid.");
return false;
}
}
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The Domain Name Is Invalid.");
return false;
}
}
if (checkTLD && domArr[domArr.length-1].length!=2 &&
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The Domain Name Extension Is Invalid");
return false;
}
if (len<2) {
alert("The Address Is Missing A Hostname.");
return false;
}
else
{if ( document.info.name.value == "" )
{
alert ( "Your Name Is Missing." );
return false;
return true;
}
}
}
</script>
<form name=info method="POST" action="form.cgi" onSubmit="return runAll()">
<p>Name:<br>
<input type="text" name="name" size="20">
<p>Email:<br>
<input type="text" name="email" size="20">
<input type="submit" value="Submit" name="B1"></form>
</body>
</html>