I have follwing function to check if the user enters blank non zero value and other then numbers in the text box
// 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="chkqt y(this.name);" tabindex="<?=$i ?>">[/HTML]
[CODE=javascript]
function chkqty(nm){
k=nm.indexOf('[');
p=nm.indexOf(']');
k=k+1;
v=nm.substr(k,p-k);
v=parseInt(v,10 );
box=document.ge tElementById("q ty["+v+"]").value;
if(parseFloat(b ox)== 0 || box.length==0) {
//just alert
alert("Error: Qty is empty!");
// document.getEle mentById(nm).fo cus();
document.getEle mentById("qty["+v+"]").value="" ;
return false;
}
else{
var checkOK = "0123456789 .";
var checkStr = document.getEle mentById("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.getEle mentById("qty["+v+"]").focus();
document.getEle mentById("qty["+v+"]").value="" ;
return (false);
}
else{
qty=document.ge tElementById("q ty1["+v+"]").value;
qty1=document.g etElementById(" qty["+v+"]").value
//alert(recqty);
//alert(drwqty);
if(qty>qty1){
alert(' qty cannot be more then qty1');
document.getEle mentById("qty["+v+"]").focus();
document.getEle mentById("qty["+v+"]").value="" ;
return false;
}
}
}
}[/CODE]
// 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="chkqt y(this.name);" tabindex="<?=$i ?>">[/HTML]
[CODE=javascript]
function chkqty(nm){
k=nm.indexOf('[');
p=nm.indexOf(']');
k=k+1;
v=nm.substr(k,p-k);
v=parseInt(v,10 );
box=document.ge tElementById("q ty["+v+"]").value;
if(parseFloat(b ox)== 0 || box.length==0) {
//just alert
alert("Error: Qty is empty!");
// document.getEle mentById(nm).fo cus();
document.getEle mentById("qty["+v+"]").value="" ;
return false;
}
else{
var checkOK = "0123456789 .";
var checkStr = document.getEle mentById("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.getEle mentById("qty["+v+"]").focus();
document.getEle mentById("qty["+v+"]").value="" ;
return (false);
}
else{
qty=document.ge tElementById("q ty1["+v+"]").value;
qty1=document.g etElementById(" qty["+v+"]").value
//alert(recqty);
//alert(drwqty);
if(qty>qty1){
alert(' qty cannot be more then qty1');
document.getEle mentById("qty["+v+"]").focus();
document.getEle mentById("qty["+v+"]").value="" ;
return false;
}
}
}
}[/CODE]
Comment