I have a simple problem, but no matter what I try, I do not see to make it work. I have a form on a php page, and I need to check the qty value in my form so that it does not exceed $ qty (the value is derived from mySQL) and not less than zero. It sounds simple - hmm, I would like to ... I had this, checking if the value was numerical, and in my attempts to do this work I even broke it - not a good morning ... lol!
Here is a tip from my JavaScript Fn:
<script type='text/javascript'>
function checkQty(elem){
var numericExpression = /^[0-9]+$/;
if(elem.value.match(numericExpression)){
return true;
}else{
alert("Quantity for RMA must be greater than zero and cannot be more than the original order!");
elem.focus();
return false;
}
}
</script>
The function is called from the submit button, onClick:
<input type="submit" name="submit" onclick="checkQty(document.getElementById('qty')";">
I tried:
var numericExpression = /^[0-9]+$/;
if(elem.value.match(numericExpression) || elem.value < 0 || elem.value > <? int($qty) ?>){
No dice .... HELP!?!
source
share