D
DaveForgotHisEngineering
I'm haven't worked with javascript in 4 years so I was wondering if
someone could help me. I've written some javascript that is supposed
to check if the input fields have been filled in and display an alert
if they are not. I've run my javascript through an online javascript
checker and it says the code is ok. However, the alert message
doesn't display when the user clicks submit and the fields aren't
filled in. I suspect that the function isEmpty() is not being run
when the user clicks submit. Thanks in advance for any suggestions
you can offer.
(Code snippet from top of page)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>GEC Consultants experts in restaurant development, restaurant
profitability
and marketing and expert witness in food services</title>
<!-- InstanceEndEditable -->
<script language="JavaScript" type="text/javascript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if
((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!
=document.MM_pgH) location.reload();
}
function isEmpty()
{
var a=document.getElementsByName("Name:").value.length;
var b=document.getElementsByName("Email:").value.length;
var c=document.getElementsByName("Telephone:").value.length;
var d=document.getElementsByName("City:").value.length;
var e=document.getElementsByName("State:").value.length;
var f=document.getElementsByName("Comments").value.length;
if(!a || !b || !c || !d || !e || !f)
{
alert("Please fill in all of the input fields and comments
section");
}
}
MM_reloadPage(true);
//-->
</script>
..
..
..
..
(Code snippet by submit button)
<h2>Please include a short story about your restaurant:</h2>
<p class="style1">
<label>
<textarea name="Comments" cols="60" rows="10"></textarea>
</label>
</p>
<p> </p>
<p>
<input type="submit" name="Submit" value="Submit"
onclick-"isEmpty()"/>
</p>
someone could help me. I've written some javascript that is supposed
to check if the input fields have been filled in and display an alert
if they are not. I've run my javascript through an online javascript
checker and it says the code is ok. However, the alert message
doesn't display when the user clicks submit and the fields aren't
filled in. I suspect that the function isEmpty() is not being run
when the user clicks submit. Thanks in advance for any suggestions
you can offer.
(Code snippet from top of page)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>GEC Consultants experts in restaurant development, restaurant
profitability
and marketing and expert witness in food services</title>
<!-- InstanceEndEditable -->
<script language="JavaScript" type="text/javascript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if
((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!
=document.MM_pgH) location.reload();
}
function isEmpty()
{
var a=document.getElementsByName("Name:").value.length;
var b=document.getElementsByName("Email:").value.length;
var c=document.getElementsByName("Telephone:").value.length;
var d=document.getElementsByName("City:").value.length;
var e=document.getElementsByName("State:").value.length;
var f=document.getElementsByName("Comments").value.length;
if(!a || !b || !c || !d || !e || !f)
{
alert("Please fill in all of the input fields and comments
section");
}
}
MM_reloadPage(true);
//-->
</script>
..
..
..
..
(Code snippet by submit button)
<h2>Please include a short story about your restaurant:</h2>
<p class="style1">
<label>
<textarea name="Comments" cols="60" rows="10"></textarea>
</label>
</p>
<p> </p>
<p>
<input type="submit" name="Submit" value="Submit"
onclick-"isEmpty()"/>
</p>