Everytime a user leaves an input, I want to check its validity before he jumps to another input box. When the input is invalid, I want the focus stays on this input box. Here is my javascript:
Code: Select all
function checkChat(chatInput) {
if (chatInput < 0 || chatInput > 1) {
alert("input invalid");
document.forms['myForm'].chat.focus();
}
}Code: Select all
<input type="text" name="chat" onblur="checkChat(this.value)" size="1" value="<? echo $value[3]; ?>">