こんにちは私はjavascriptに不慣れです。
ここで使用されている手法を使用して、JavaScriptフォームの検証を実装しようとしています: http ://www.w3schools.com/js/tryit.asp?filename = tryjs_form_validationフォーム の空のフィールドをテストし、アラートを使用しますユーザーに警告するが、私には機能しません空のフォームを送信すると、jspファイルに進み、javascriptがエラーをキャッチしません
これが私のindex.htmlファイルです。フォームは
<html>
<body>
<head>
<script>
function validateForm()
{
var stoneField=document.forms["bmiForm"]["stone"].value;
var poundsField=document.forms["bmiForm"]["pounds"].value;
var kgsField=document.forms["bmiForm"]["kgs"].value;
var feetField=document.forms["bmiForm"]["feet"].value;
var inchesField=document.forms["bmiForm"]["inches"].value;
if ( stoneField = null || stoneField = "" && poundsField = null || poundsField = "" && kgsField = null || kgsField = "" && feetField = null || feetField = "" && inchesField = null || inchesField = "" )
{
alert("Please enter a weight and height");
return false;
}
else
{
return true;
}
}
</script>
</head>
<form name ="bmiForm" action="PrintBMI.jsp" onsubmit="return validateForm()" method=post style="width:250px;">
<fieldset>
<legend>BMI Calculator</legend>
<h3>Enter your weight</h3>
Stone <input type = text name = "stone" size = 1 maxlength = 2>
Pounds <input type = text name = "pounds" size = 1 maxlength = 2>
<br>
<strong>OR</strong>
<br>
KGs <input type = text name = "kgs" size = 1 maxlength = 3>
<h3>Enter your height</h3>
Feet <input type = text name = "feet" size = 1 maxlength = 1>
Inches <input type = text name = "inches" size = 1 maxlength = 2>
<br>
<strong>OR</strong>
<br>
Metres <input type = text name = "metres" size = 1 maxlength = 4>
<p><input type=submit value = "Get BMI">
</fieldset>
</form>
</body>
</html>'
誰かが私が間違っていることを見ていますか?御時間ありがとうございます。