tags:

views:

157

answers:

4

Javascript code is

function jsCheck() {
var msg = '';

//Move email checker to first line of javascript validation
if (document.form1.email.value.indexOf(".") <= 3  && document.form1.email.value.indexOf("@") <= 2){ msg = msg + 'Valid Email Address\n'; }
if (document.form1.name.value == ""){ msg = msg + 'Full Name\n'; }
if (document.form1.company.value == ""){ msg = msg + 'Company Name\n'; }
if (document.form1.telephone.value == ""){ msg = msg + 'Telephone No\n'; }
if (document.form1.country.value == ""){ msg = msg + 'Country\n'; }

if (msg != ''){
alert('The following fields are missing\n\n' + msg);
return false;
}

form name="form1" method="post" action="apply_confirm.asp" onSubmit="return jsCheck();"

Why the javascript is not getting called

+5  A: 

Well, if your original posting is accurate (a number of things have changed as people have attempted to make your post legible), it's because everything you posted is enclosed in HTML comments, <!-- ... -->.

And yeah, as far as providing the solution as soon as possible goes, you might want to keep in mind that we don't work for you.

chaos
+2  A: 

You most likely have an error in your javascript code.

  1. Test your javascript in Firefox.
  2. Open the error console with CTRL+SHIFT+J or Tools -> Error Console.
  3. Look for an error message or warning explaining the javascript error.
  4. If you are unsure what the error message means, add it to the question so we can explain it to you.
too much php
+2  A: 

Try this:

 <html>
<head>
<script type="text/javascript">
function jsCheck() {
var msg = '';

//Move email checker to first line of javascript validation
if (document.form1.email.value.indexOf(".") <= 3  && document.form1.email.value.indexOf("@") <= 2){ msg = msg + 'Valid Email Address\n'; }
if (document.form1.name.value == ""){ msg = msg + 'Full Name\n'; }
if (document.form1.company.value == ""){ msg = msg + 'Company Name\n'; }
if (document.form1.telephone.value == ""){ msg = msg + 'Telephone No\n'; }
if (document.form1.country.value == ""){ msg = msg + 'Country\n'; }

if (msg != ''){
alert('The following fields are missing\n\n' + msg);
return false;
}
return true;
}
</script>

</head>
<body>
<form name="form1" method="post" action="apply_confirm.asp" onSubmit="return jsCheck();">
<input type='text' id='name'/>
<input type='text' id='company'/>
<input type='text' id='email'/>
<input type='text' id='telephone'/>
<input type='text' id='country'/>
<input type='submit' value='submit'/>
</form>
</body>
</html>
krishna
+1 for effort, Hardly likely that the poster will select an "answer" from the collective here.
Joshua