価格フィールドを検証しようとしています。私はこれを試していました:
var productId = document.getElementById("productId");
var productName = document.getElementById("productName");
var productPrice = document.getElementById("price");
alert(isFinite(productPrice.value));
if(isNaN(productPrice.value)||!isFinite(productPrice.value)){
error = document.getElementById("priceError");
error.innerHTML = "Please enter correct value";
productPrice.style.border="thin solid red";
}else{
error = document.getElementById("priceError");
error.innerHTML = "";
}
入力がスペース/複数のスペースのみの場合、ラインアラートは私に真を与えています。これは私の HTML ページです。
<td>Price</td>
<td><input type = "text" id = "price" size = "14"/></td>
ありがとう