Var form=document. Forms [0];
Form. The elements [0]. AddEventListener (" focus ", handler);
Form. The elements [1]. The addEventListener (" focus ", handler);
Form. The elements [0]. AddEventListener (" blur ", handler);
Form. The elements [1]. The addEventListener (" blur ", handler);
Form. The elements [0]. AddEventListener (" change ", handler);
Form. The elements [1]. The addEventListener (" change ", handler);
The function handler (even) {
If (even type=="focus") {
If (even) target) style backgroundColor! {
="red")Even the target. Style. BackgroundColor="yellow";
}
} else if (even) type=="blur") {
If (even) target) style backgroundColor! {
="red")Even the target. Style. BackgroundColor="";
}
} else if (even) type=="change") {
If (/[^ \] d/. The test (value) even. Target.) {
Even the target. Style. BackgroundColor="red";
} else {
Even the target. Style. BackgroundColor="";
}
}
}
}
</script>
<body>