I have a simple HTML form(see below) that is giving me a headache. You can copy and paste the code into a text file and run it.
If you run the code you will see that my two field checks work fine when there is an error. However, when there is no error, the form should be calling my webpage(google for this example). It doesn't do anything.
If I remove the code that checks for the Upload File, everything works fine. What is it about the DOM call that causes my script to fail?
I'm getting some Advil
<form name="banner_ad" action=" method="post">
<b>Choose Zip Code: </b>
<input type="text" name="zip_code" maxlength = "5" />
<b>Select image file: </b><input id="file_name" name="userfile[]" type="file"/><br>
<input type="submit" value="Upload image" onClick="
// Zip code
var zip_code_txt = zip_code.value;
if (zip_code_txt.length != 5)
{
alert('Invalid Zip Code');
return false;
}
// Upload File
if (document.getElementById('file_name').value == '')
{
alert('Choose an image file to upload.');
return false;
}
return true;
">
If you run the code you will see that my two field checks work fine when there is an error. However, when there is no error, the form should be calling my webpage(google for this example). It doesn't do anything.
If I remove the code that checks for the Upload File, everything works fine. What is it about the DOM call that causes my script to fail?
I'm getting some Advil
<form name="banner_ad" action=" method="post">
<b>Choose Zip Code: </b>
<input type="text" name="zip_code" maxlength = "5" />
<b>Select image file: </b><input id="file_name" name="userfile[]" type="file"/><br>
<input type="submit" value="Upload image" onClick="
// Zip code
var zip_code_txt = zip_code.value;
if (zip_code_txt.length != 5)
{
alert('Invalid Zip Code');
return false;
}
// Upload File
if (document.getElementById('file_name').value == '')
{
alert('Choose an image file to upload.');
return false;
}
return true;
">