// this is in the for loop but tabindex goes ahead and fires the event again how do i prevent the tabindex going to the next textbox
[HTML]<input type="text" name="<?='qty['.$i.']'?> id="<?='qty['.$i.']'?>" onchange="chkqty(this.name);" tabindex="<?=$i?>">[/HTML]
Expand|Select|Wrap|Line Numbers
- function chkqty(nm){
- k=nm.indexOf('[');
- p=nm.indexOf(']');
- k=k+1;
- v=nm.substr(k,p-k);
- v=parseInt(v,10);
- box=document.getElementById("qty["+v+"]").value;
- if(parseFloat(box)== 0 || box.length==0) {
- //just alert
- alert("Error: Qty is empty!");
- // document.getElementById(nm).focus();
- document.getElementById("qty["+v+"]").value="";
- return false;
- }
- else{
- var checkOK = "0123456789.";
- var checkStr = document.getElementById("qty["+v+"]").value;
- var allValid = true;
- for (i = 0; i < checkStr.length; i++)
- {
- ch = checkStr.charAt(i);
- for (j = 0; j < checkOK.length; j++)
- if (ch == checkOK.charAt(j))
- break;
- if (j == checkOK.length)
- {
- allValid = false;
- break;
- }
- }
- if (!allValid)
- {
- alert("Please enter only numbers in the \"Qty \" field.");
- document.getElementById("qty["+v+"]").focus();
- document.getElementById("qty["+v+"]").value="";
- return (false);
- }
- else{
- qty=document.getElementById("qty1["+v+"]").value;
- qty1=document.getElementById("qty["+v+"]").value
- //alert(recqty);
- //alert(drwqty);
- if(qty>qty1){
- alert(' qty cannot be more then qty1');
- document.getElementById("qty["+v+"]").focus();
- document.getElementById("qty["+v+"]").value="";
- return false;
- }
- }
- }
- }