|
All,
I have a questions with onChange with some dummy code below:
function checkVal(lcInput) {
if(lcInput.value!="") { var lcValueHold = lcInput.value; alert("You're invalid"); lcInput.focus(); lcInput.value=lcValueHold; lcInput.select(); return false; }
}
where used:
<input type="text" name="Maturity_From" size="9" maxlength="12" value="MM/DD/YYYY" onfocus="this.value=''" onchange="checkVal2(this)" />
my goal: if invalid text (right now it's just any text in the field is invalid), I want to keep the cursor inside the field with the text highlighted.
It works really nice in all browsers with the RETURN key, but not the TAB. The script runs with the alert, and the text selected, but the cursor goes to the next field.
I don't want it to go to the next field but stay inside the field if the text is invalid. I can't use onblur.
Any suggestions?
Thanks.
|