----------ソルバード------------HTML形式のJavascriptによる検証が機能しない
フォームの検証をしようとしていますフィールドのいずれかが空白のままされている場合という、警告があり、フォームは文句を言わない通過、それはまだこれらの2行に、データベース
function validateAdd() {
var a = document.add_product.product_id.value;
var b = document.add_product.brand.value;
var c = document.add_product.model.value;
var h = document.add_product.description.value;
var d = document.add_product.cam_mpx.value;
var e = document.add_product.storage.value;
var f = document.add_product.more_storage.value;
var g = document.add_product.price.value;
if (a == "" || b == "" || c == "" || d == "" || e == "" || f = "" || g == "" || h == "" ||
a == null || b == null || c == null || d == null || e == null || f = null || g == null || h == null) {
alert("All fields must be filled in");
return false;
}
}
<form name="add_product" action="index.php" method="post" onsubmit="return validateAdd()">
<label>Product ID:</label><br>
<input type="text" name="product_id"><br>
<label>Brand:</label><br>
<input type="text" name="brand"><br>
<label>Model:</label><br>
<input type="text" name="model"><br>
<label>Description:</label><br>
<input type="text" name="description"><br>
<label>Camera Megapixel:</label><br>
<input type="text" name="cam_mpx"><br>
<label>Storage:</label><br>
<input type="text" name="storage"><br>
<label>Expandable Storage?:</label><br>
<input type="text" name="more_storage"><br>
<label>Price:</label><br>
<input type="text" name="price"><br>
<button class="button" type="submit" name="save" onclick="return confirm('Are you sure you want to add this to the system?')">Add</button><br>
<p></p>
</form>
Javascriptのデバッグを試したことがありますか?すべての主要なブラウザには、これらのデバッグツールが組み込まれています。 – cteski
AN入力の値はnullにはなりません。 – epascarello
コンソール出力とは何ですか?デバッグをしましたか? –