フォームデータをチェックするためのコードがあり、その理由がわかりません。フォームデータを確認するJavascriptが機能しない
<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" />
ありがとうございます!
それはそれでした!私はそれを修正した後、フォームはまだ完了しましたが、続行する代わりにフォームに戻るためには何を変更する必要がありますか?ありがとう – Intelwalk
それはどのようにこの関数を呼び出すかによって異なります。 –
ボタンを押したときにonsubmitと呼んでいます。 – Intelwalk