function check(obj){
if(obj.value!="000000"){
obj.focus();
obj.style.backgroundColor="#FF0000";
alert("Error!");
}
}
if(obj.value!="000000"){
obj.focus();
obj.style.backgroundColor="#FF0000";
alert("Error!");
}
}
<head>
<title>Untitled</title>
<script language="javascript">
var checked = false;
function nextFocus(obj){
if(obj.value.length >= obj.maxLength){
check(obj);
document.form1.txt2.focus();
}
}function check(obj){
if(obj.value!="000000"){
obj.style.backgroundColor="#FF0000";
if(event.type=="blur") alert("Error!");
}
}</script>
</head><body>
<form name="form1">
<input type="text" name="txt1" maxlength="6" onkeyup="nextFocus(this)" onblur="check(this)">
<input type="text" name="txt2">
</form>
</body>
</html>
function check(obj){
if(obj.value!="000000"){
obj.style.backgroundColor="#FF0000";
if(confirm("Edit it?")){
obj.focus();
}
}
}