I'm using JS for the first time. Can't seem to call an external JS function at all. I have a HTML form and im trying to call a function so if the first name box is empty, I get a message saying to fill in a name.
My form
<head>
<script type="text/javascript" src="scripts/validation.js"></script>
</head>
<body>
<form name="myForm" method="post" action="somewhere.html"
onsubmit="validation()">
<fieldset id="PersonalDetails">
<legend>Personal Details</legend>
<div class="form" id="firstname">
<p>First Name: <br />
<input type="text" name="firstname" />
</p>
</div>
</fieldset>
</form>
</body>
In the JS file:
function validation(){
var x=document.forms["myForm"]["firstname"].value;
if (x==null || x=="")
{
alert("First name must be filled out!!!!");
return false;
}
}