检查一段字符串是否全由数字组成
<script language="Javascript"><!--
function checkNum(str){return str.match(/\D/)==null}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
// --></script>简单的检查输入email是否合法程序
<script language="VBScript"><!--
function chkEmail(email)
on error resume next
dim i,l,pos1,pos2
chkEmail=true
if isnull(email) then chkEmail=false:exit function
pos1= instr(email,"@")
pos2=instrRev(email,".")
if not(pos1>0) or not (pos2>0) or pos1>pos2 then
chkEmail=false
end if
if err.number<>0 then err.clear
end function
--></script>
<script language="Javascript"><!--
function checkNum(str){return str.match(/\D/)==null}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
// --></script>简单的检查输入email是否合法程序
<script language="VBScript"><!--
function chkEmail(email)
on error resume next
dim i,l,pos1,pos2
chkEmail=true
if isnull(email) then chkEmail=false:exit function
pos1= instr(email,"@")
pos2=instrRev(email,".")
if not(pos1>0) or not (pos2>0) or pos1>pos2 then
chkEmail=false
end if
if err.number<>0 then err.clear
end function
--></script>
将该函数添加到text对象的onKeyPress事件中
function isIntChk(evt)
{
var CharCode=(window.Event)? evt.which:evt.keyCode;
if((CharCode>31)&&(CharCode<48||CharCode>57))
{
return(false);
}
return(true);
}
判断是否是合法的email,关键是判断是否有字符@,及其个数必须为1,@的前后必需有字符...具体的你自己写个函数就是了 应该不难。