isNumeric isInteger isDate

<%@ Language=VBScript %>
None.gif < script language = " javascript "  runat = " server " >  
None.gif
function  isNumeric(strNumber) { 
None.gif
return  (strNumber.search( /^ ( -| \ + ) ? \d + (\.\d + ) ? $ / !=   - 1 ); 
None.gif
None.gif
function  isUnsignedNumeric(strNumber) { 
None.gif
return  (strNumber.search( /^ \d + (\.\d + ) ? $ / !=   - 1 ); 
None.gif
None.gif
function  isInteger(strInteger) { 
None.gif
return  (strInteger.search( /^ ( -| \ + ) ? \d + $ / !=   - 1 ); 
None.gif
None.gif
function  isUnsignedInteger(strInteger) { 
None.gif
return  (strInteger.search( /^ \d + $ / !=   - 1 ); 
None.gif
None.gif
</ script >  

None.gif function  isDateShort(strDate)
None.gif{
None.gif
return  FormatValue(strDate);
None.gif}


None.gif < SCRIPT LANGUAGE = " VBSCRIPT "  RUNAT = " SERVER " >
None.gif
Function  FormatValue(Value)
None.gif FormatValue 
=   isDate (Value)
None.gif
End Function
None.gif
</ SCRIPT >
None.gif < SCRIPT LANGUAGE = " VBSCRIPT "  RUNAT = " SERVER " >
None.gif
Function  FormatValue(Value)
None.gif    isS 
=   isDate (Value)
None.gif    
dim     nowDates
None.gif    
if  isS = true   then
None.gif        nowDates 
=  Value
None.gif    
else
None.gif        nowDates 
=   left (Value, 4 &   " - "   &   mid (Value, 5 , 2 &   " - "   &   right (Value, 2 )
None.gif    
end   if
None.gif    
if   isDate (nowDates) = true   then
None.gif        FormatValue 
=  Value
None.gif    
else
None.gif        FormatValue 
=   " "
None.gif
     end   if
None.gif
End Function
None.gif
</ SCRIPT >

<HTML>
<BODY>
<b>判断数字的正确性</b>
<%
Dim strTemp
strTemp = CStr(Request.Form("inputstring"))
If strTemp = "" Then strTemp = "0"
%>
<TABLE BORDER="1" CELLPADDING="4" CELLSPACING="2">
<TR>
<TD ALIGN="right"><B>原始字符串</B></TD>
<TD><%= strTemp %></TD>
</TR>
<TR>
<TD ALIGN="right"><B>数字</B></TD>
<TD><%=isNumeric(strTemp)%></TD>
</TR>
<TR>
<TD ALIGN="right"><B>非负数字</B></TD>
<TD><%=isUnsignedNumeric(strTemp)%></TD>
</TR>
<TR>
<TD ALIGN="right"><B>整数</B></TD>
<TD><%=isInteger(strTemp)%></TD>
</TR>
<TR>
<TD ALIGN="right"><B>非负整数()</B></TD>
<TD><%=isUnsignedInteger(strTemp)%></TD>
</TR>
</TABLE>
<FORM ACTION="<%=Request.ServerVariables("SCRIPT_NAME")%>" METHOD="post">
请输入一个数字:<BR>
<INPUT TYPE="text" NAME="inputstring" SIZE="50"></INPUT><BR>
<INPUT TYPE="submit" Value="提交"></INPUT><BR>
</FORM>
</BODY>
</HTML>

转载于:https://www.cnblogs.com/austinleng/archive/2005/04/21/142779.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值