【发布时间】:2011-01-31 14:16:30
【问题描述】:
我想通过 Javascript 使用 IF OR 函数检查文本框的值是否为空,以及文本框是否大于 0。
我的代码如下:
if(qty != "" && qty <> "0"){
//
}
其中 qty 是 HTML 输入字段的名称和 ID
这是完整更新代码的一部分。
if(qty != "")
{
if(/^\d+$/.test(qty.value)){
var value = parseint(qty.value, 10);
sizeID = document.getElementById("size" + colID + prodID).value;window.location = "/_nCartAddToBasket.asp?ProductID=" + prodID + "&ProductColourID=" + colID + "&ProductSizeID=" + sizeID + "&Qty=" + qty + "&fgID=" + fgID;
}else{
alert("You must enter a numeric value in the quantity field.");}
}else{
alert("You must enter a quantity before adding to your basket.");}
}
【问题讨论】:
-
你是指文本字段还是文本区域?
-
Textfield
code输入数量:
标签: javascript ajax xhtml input