文本框失去焦点后js判断输入是否为数字
(2018-04-28 12:42:48)
标签:
aspjs |
文本框失去焦点后js判断输入是否为数字
━━━━━━━━━━━━━━━━━━━━━━━━━
< html >
< head >
< title > 文本框失去焦点后js判断输入是否为数字 < / title >
< scriptType = "text/javascript" >
Function ischeckNum()
{
varnum = Document.getElementById('isnum').value;
If( num )
{
If(! isNaN( num ) )
{
alert('是数字');
returnFalse;
}
Else
{
alert('你输入的数据不是数字');
Document.getElementById('isnum').value=" ";
Document.getElementById('isnum').focus();
returnFalse;
}
}
Else
{
alert('需输入内容');
Document.getElementById('isnum').focus();
}
}
< / script >
< / head >
< body >
< Form method
= "post" action = "" >
< inputType = "text" name = "isnum" id
= "isnum" onblur
= "ischeckNum();" >
< / Form >
< / body >
< / html >
━━━━━━━━━━━━━━━━━━━━━━━━━
< html >
< head >
< title > 文本框失去焦点后js判断输入是否为数字 < / title >
< script
Function
{
var
If(
{
If(
{
return
}
Else
{
alert('你输入的数据不是数字');
Document.getElementById('isnum').value=
return
}
}
Else
{
alert('需输入内容');
Document.getElementById('isnum').focus();
}
}
< / script >
< / head >
< body >
< Form
< input
< / Form >
< / body >
< / html >
前一篇:focus()函数作用