<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>jquery mobile phone number input tips </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-magnifier. Mag-explain {
border-top:1px solid #E6C99E;
Color: #6C6C6C;
font-size:12px;
margin-top:5px;
width:190px;
}
. Fn-hide{display:none}
</style>
<script type= "Text/javascript" src= "Jquery1.3.2.js" ></script>
<script>
$ (function () {
$ ("#k"). Focus (function (EVT) {
$ (this). AddClass ("a");
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 ("a");
E ();
This.value=this.value
})
})
Calculates the left and top of the Div, showing 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 Div
function e () {
$ ("#textMag"). AddClass ("Fn-hide")
}
Control the numbers 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>
<body>
<div id= "Main" >
Mobile: <input type= "text" id= "K" maxlength= "one" class= "I-text" value= ""/><div class= "Text-magnifier fn-hide" id = "Textmag" >
<div id= "Mag-text" class= "Mag-text" ></div>
<div class= "Mag-explain" > Mobile phone number is 11 digits </div>
<div>http://www.999jiujiu.com/</div>
</body>
jquery Mobile number input hint