Hi,
I've got these form fields that i need to check wiether the value of this field is less than zero. If so, give an alert message and select this field.
and the function:
this works perfect exept for the document.forms['invoeren' ].elements['bestellen_' + nummer+'_'+i].select();
After perssing the TAB-button, de alertmessage appears, the value is set to zero but the focus is on the next textfield instead of back to the invalid textfield.
Can I overcome this? I saw a simular problem here a solution was to execute de select() with a setTimout.
But how do I do this with my funtions? Where do I set the quotes??
does NOT work....
Ynse
I've got these form fields that i need to check wiether the value of this field is less than zero. If so, give an alert message and select this field.
Code:
<form name="invoeren">
<input type ="bestellen_1_1" onChange="Optellen(1,4)">
<input type ="bestellen_1_2" onChange="Optellen(1,4)">
<input type ="bestellen_1_3" onChange="Optellen(1,4)">
<input type ="bestellen_1_4" onChange="Optellen(1,4)">
<input type ="bestellen_2_1" onChange="Optellen(2,3)">
<input type ="bestellen_2_2" onChange="Optellen(2,3)">
<input type ="bestellen_2_3" onChange="Optellen(2,3)">
and the function:
Code:
function Optellen(nummer,eind) {
som = 0;
for(i=1;i<eind;i++)
{
a = parseFloat(document.forms['invoeren' ].elements['bestellen_' + nummer+'_'+i].value);
if(document.forms['invoeren' ].elements['bestellen_' + nummer+'_'+i].value.length==0)
{
a=0;
}
if(document.forms['invoeren' ].elements['bestellen_' + nummer+'_'+i].value<0)
{
a=0;
document.forms['invoeren' ].elements['bestellen_' + nummer+'_'+i].value=0;
alert('The value can\'t be less than zero!');
document.forms['invoeren' ].elements['bestellen_' + nummer+'_'+i].select();
}
som += a;
}
this works perfect exept for the document.forms['invoeren' ].elements['bestellen_' + nummer+'_'+i].select();
After perssing the TAB-button, de alertmessage appears, the value is set to zero but the focus is on the next textfield instead of back to the invalid textfield.
Can I overcome this? I saw a simular problem here a solution was to execute de select() with a setTimout.
But how do I do this with my funtions? Where do I set the quotes??
Code:
setTimeout("document.forms['invoeren' ].elements['bestellen_' + nummer+'_'+i].select()",1);
Ynse