I have the following javascript funciton:
function chkHourlyRate()
{
if (isNaN(document.frmCRA.hourly_rate.value))
{
window.alert("You must enter a valid whole number or decimal number for rate."
frmCRA.hourly_rate.focus();
frmCRA.hourly_rate.select();
}
}
I have the following 3 text boxes defined inside a form:
$ <INPUT TYPE="TEXT" NAME="hourly_rate" MAXLENGTH=7 SIZE=4 onChange="chkHourlyRate()"> x
<INPUT TYPE="TEXT" NAME="total_hours" MAXLENGTH=7 SIZE=4 onBlur="calculatePay()"> HRS = $
<INPUT TYPE="TEXT" NAME="total_pay" MAXLENGTH=7 SIZE=5>
When I enter a invalid number into the hourly_rate text box and press the tab key to go to the next text box, it displays an error but it will not stay focus and selected on this same box, the box that has the invalid number. How can reposition the curser or stop the tab to go forward and refocus on the text box that has the invalid number entered?
I thought that the code above would work but it doesn't. Have some idea?
function chkHourlyRate()
{
if (isNaN(document.frmCRA.hourly_rate.value))
{
window.alert("You must enter a valid whole number or decimal number for rate."
frmCRA.hourly_rate.focus();
frmCRA.hourly_rate.select();
}
}
I have the following 3 text boxes defined inside a form:
$ <INPUT TYPE="TEXT" NAME="hourly_rate" MAXLENGTH=7 SIZE=4 onChange="chkHourlyRate()"> x
<INPUT TYPE="TEXT" NAME="total_hours" MAXLENGTH=7 SIZE=4 onBlur="calculatePay()"> HRS = $
<INPUT TYPE="TEXT" NAME="total_pay" MAXLENGTH=7 SIZE=5>
When I enter a invalid number into the hourly_rate text box and press the tab key to go to the next text box, it displays an error but it will not stay focus and selected on this same box, the box that has the invalid number. How can reposition the curser or stop the tab to go forward and refocus on the text box that has the invalid number entered?
I thought that the code above would work but it doesn't. Have some idea?