日期:2009-10-24  浏览次数:20851 次

<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");
            break
        case "r":
            res=new RegExp("(^([\+\-]?[1-9])[0-9]*(\.[0-9]+)?[0-9]$)|(^([\+\-]?[0-9]\.)[0-9]+$)","g")
            break;
        case "f":
            res=new RegExp("(^(0\.)[0-9]+$)|(^[\+\-]0\.[0-9]+$)","g");
            break;
        case "l":
            res=new RegExp("^[a-z]+$","gi");
            break;