I want to check if a textbox value is empty and also if the textbox is greater than 0 with IF OR function via Javascript.
My code is below:
if(qty != "" && qty <> "0"){
//
}
Where qty is the name and id of the HTML input field
THIS IS THE SOME PORTION FROM THE FULL UPDATED CODE.
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.");}
}
I edited your question a little in order to have it make some sense. Your text element cannot be both empty and greater than zero at the same time.
That makes sure that the value of the text element is a string of one or more digits.