JQuery mobile phone number input prompt, jquery mobile phone number input
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> jQuery mobile phone number input prompt </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Style>
* {Margin: 0; padding: 0 ;}
# Main {width: 728px; height: 300px; padding: 60px; margin: 0 auto; border: 5px solid # CCC ;}
Input {border: 1px solid #666 ;}
. A {border: 1px solid red ;}
. Text-magnifier {
Background: none repeat scroll 0 0 # FFFFE4;
Border: 1px solid # E6C99E;
Color: # FF4800;
Height: 50px;
Left: 170px;
Padding: 5px 0 0 10px;
Position: absolute;
Top: 30px;
Width: 200px;
Font: 20px Tahoma, Helvetica, Arial, Simsun, sans-serif;
}
. Text-magniier. mag-explain {
Border-top: 1px solid # E6C99E;
Color: # 6C6C6C;
Font-size: 12px;
Margin-top: 5px;
Width: pixel PX;
}
. Fn-hide {display: none}
</Style>
<Script type = "text/javascript" src = "jquery1.3.2.js"> </script>
<Script>
$ (Function (){
$ ("# K"). focus (function (evt ){
$ (This). addClass ("");
If (this. value. length> 0 ){
A (this );
D (this );
}
})
$ ("# K"). keyup (function (evt ){
If (this. value. length = 0 ){
E ();
} Else {
A (this );
}
D (this );
})
$ ("# K"). blur (function (evt ){
$ (This). removeClass ("");
E ();
This. value = this. value
})
})
// Calculate the left and top of the div and display the div
Function a (evt ){
Var y = 20;
Y = $ (evt). outerHeight ();
$ ("# TextMag"). removeClass ("fn-hide ");
Var t = $ (evt). offset (). top;
Var l = $ (evt). offset (). left;
$ ("# TextMag" ).css ({
"Top": (t + y) + "px ",
"Left": l + "px"
});
}
// Hide the div
Function e (){
$ ("# TextMag"). addClass ("fn-hide ")
}
// Control the number displayed in the div
Function d (e ){
Var I = e. value;
I = $. trim (I );
Var h = I. substring (0, 3 );
I = I. substring (3 );
While (I & I. length> 0 ){
H + = "" + I. substring (0, 4 );
I = I. substring (4)
}
$ ("# Mag-text" ).html (h );
}
</Script>
</Head>
<Body>
<Div id = "main">
Mobile phone number: <input type = "text" id = "k" maxlength = "11" class = "I-text" value = ""/> <div class = "text-magniier fn- hide "id =" textMag ">
<Div id = "mag-text" class = "mag-text"> </div>
<Div class = "mag-explain"> the mobile phone number is an 11-digit number. </div>
<Div> http://www.999jiujiu.com/</div>
</Body>
</Html>