首页 > 学院 > 开发设计 > 正文

在客户端JAVASCRITP处理TEXTFORM的函数

2019-11-18 13:36:53
字体:
来源:转载
供稿:网友

  <Html>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<FORM action="" method=post id=form1 name=form1 onsubmit="return CheckForm()">

<P><INPUT id=text1 name=text1><INPUT id=submit1 name=submit1 type=submit value=Submit></P></FORM>
<P> </P>
<P> </P>
<P> </P>
<SCRipT LANGUAGE=javascript>
<!--
function KillSpace(x){
        while((x.length>0) && (x.charAt(0)==' '))
                x = x.substring(1,x.length);
        while((x.length>0) && (x.charAt(x.length-1)==' '))
                x = x.substring(0,x.length-1);
        return x;
}

function CheckText(Obj,TypeValue,Msg,Necessary)
{
    /*TypeValue
    'd': Numeric;
    'i': All Integer
    'r': Aeal Number
    'f': Decimal Fraction
    'l': 26 letter
    'ul':[A-Z]
    'll':[a-z]
    'w': [a-zA-Z_0-9]
    'S': Chinese Characters and Special Characters
    
    Obj Required.
    Msg Return PRompt Message
    Necessary is Optional Parameter
    */
    if (isNaN(Necessary))
        Necessary=false;
    Obj.value=KillSpace(Obj.value);
    switch (TypeValue)
    {
        case "d":
            res=new RegEXP("^[0-9]+$","g");
            break;
        case "i":
            res=new RegExp("(^[1-9][0-9]*$)(^[/+/-][1-9][0-9]*$)","g");


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表