I am not sure what is wrong so I just thought of asking you all. I want to validate some variables via JS before I send them to my PHP Script, but somehow it's not working as I want and I am not sure why. Here my example code :
HTML
<script src="jadd.js" type="text/javascript"></script>
<form name="jadd" action="./func/add_job.php" method="post" onsubmit="return vf()">
<a href="javascript:document.jadd.submit()">random submit</a>
...
<input type="text" size="100" maxlength="150" name="jt" />
...
</form>
Javascript (jadd.js):
function vf() {
var x=document.forms["jadd"]["jt"].value;
if (x==null || x=="") {
alert("Field must be filled out");
return false;
}
}
Try using
vf_addjob()
instead ofvf()
should be :