script function myx switch this attr id case phone alert default-1 bre

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<script>
function myx(){
switch($(this).attr("id")){
case "phone":
alert("default-1"); break;
case "name":
alert("default-2"); break;
case "street":
alert("default-3"); break;
default:
alert("default");
}
}
</script>
<input type="text" id="phone" onKeyPress='myx();'>
<input type="text" id="name">
<input type="text" id="street">