У меня есть следующий код для проверки данных формы, и я не могу понять, почему он не работает.
<script type="text/javascript">
function checkStuff() {
// By default, we plan to submit the form.
var formOkay = 1;
// Check to see if field_1 has a value. If not, we note that by changing our variable.
if(document.getElementById('requestorfirstname').value == '')
formOkay = 0;
// Let the user know something is wrong somehow. An alert is easiest.
alert('Requestor Name Required!');
// If you return true the form will submit. If you return false it will not.
if(formOkay == 1) {
return true;
} else {
return false;
}
}
</script>
Теперь вот часть HTML-формы, которую он проверяет на отправке.
<input type="text" name="requestorfirstname" />
Спасибо за помощь!