I create a simple HTML form and call the JavaScript file through the onsubmit event handler. Oddly enough, whenever I press the submit button, my JS file does not work. Help?
** UPDATED CODES
This is what I have for my compressed HTML file:
<html>
<form name="form01" id="form01" action="http://itins3.madisoncollege.edu/echo.php"
method="post" onsubmit="return checkAllTextBoxes();">
<label for="actualFirstName" class="setWidth">First Name:</label>
<input type="text" name="actualFirstName" id="actualFirstName" />
<input type="submit" value="Send Form" />
</form>
</html>
<script src="/javaScriptFiles/newArtist.js" type="text/javascript"></script>
This is what I have for my JS file:
function checkAllTextBoxes()
{
if (document.form01.actualFirstName.value.length < 2)
{
alert("First name is too short- must be at least two characters or more.");
return false;
}
return true;
}
I am trying to figure out what went wrong, but cannot find an error in my code. Tried JSHint, Firebug (FireFox) and even online HTML validators and no errors. Another pair of coding eyes will be of great help. Thank you
source
share