isNumeric isInteger isDate
生活随笔
收集整理的這篇文章主要介紹了
isNumeric isInteger isDate
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
<%@ Language=VBScript %>
<script?language="javascript"?runat="server">?
function?isNumeric(strNumber)?{?
return?(strNumber.search(/^(-|\+)?\d+(\.\d+)?$/)?!=?-1);?
}?
function?isUnsignedNumeric(strNumber)?{?
return?(strNumber.search(/^\d+(\.\d+)?$/)?!=?-1);?
}?
function?isInteger(strInteger)?{?
return?(strInteger.search(/^(-|\+)?\d+$/)?!=?-1);?
}?
function?isUnsignedInteger(strInteger)?{?
return?(strInteger.search(/^\d+$/)?!=?-1);?
}?
</script>? function?isDateShort(strDate)
{
return?FormatValue(strDate);
}
Function?FormatValue(Value)
?FormatValue?=?isDate(Value)
End?Function
</SCRIPT> <SCRIPT?LANGUAGE="VBSCRIPT"?RUNAT="SERVER">
Function?FormatValue(Value)
????isS?=?isDate(Value)
????dim????nowDates
????if?isS=true?then
????????nowDates?=?Value
????else
????????nowDates?=?left(Value,4)?&?"-"?&?mid(Value,5,2)?&?"-"?&?right(Value,2)
????end?if
????if?isDate(nowDates)=true?then
????????FormatValue?=?Value
????else
????????FormatValue?=?""
????end?if
End?Function
</SCRIPT>
<HTML>
<BODY>
<b>判斷數(shù)字的正確性</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>數(shù)字</B></TD>
<TD><%=isNumeric(strTemp)%></TD>
</TR>
<TR>
<TD ALIGN="right"><B>非負數(shù)字</B></TD>
<TD><%=isUnsignedNumeric(strTemp)%></TD>
</TR>
<TR>
<TD ALIGN="right"><B>整數(shù)</B></TD>
<TD><%=isInteger(strTemp)%></TD>
</TR>
<TR>
<TD ALIGN="right"><B>非負整數(shù)()</B></TD>
<TD><%=isUnsignedInteger(strTemp)%></TD>
</TR>
</TABLE>
<FORM ACTION="<%=Request.ServerVariables("SCRIPT_NAME")%>" METHOD="post">
請輸入一個數(shù)字:<BR>
<INPUT TYPE="text" NAME="inputstring" SIZE="50"></INPUT><BR>
<INPUT TYPE="submit" Value="提交"></INPUT><BR>
</FORM>
</BODY>
</HTML>
<script?language="javascript"?runat="server">?
function?isNumeric(strNumber)?{?
return?(strNumber.search(/^(-|\+)?\d+(\.\d+)?$/)?!=?-1);?
}?
function?isUnsignedNumeric(strNumber)?{?
return?(strNumber.search(/^\d+(\.\d+)?$/)?!=?-1);?
}?
function?isInteger(strInteger)?{?
return?(strInteger.search(/^(-|\+)?\d+$/)?!=?-1);?
}?
function?isUnsignedInteger(strInteger)?{?
return?(strInteger.search(/^\d+$/)?!=?-1);?
}?
</script>? function?isDateShort(strDate)
{
return?FormatValue(strDate);
}
Function?FormatValue(Value)
?FormatValue?=?isDate(Value)
End?Function
</SCRIPT> <SCRIPT?LANGUAGE="VBSCRIPT"?RUNAT="SERVER">
Function?FormatValue(Value)
????isS?=?isDate(Value)
????dim????nowDates
????if?isS=true?then
????????nowDates?=?Value
????else
????????nowDates?=?left(Value,4)?&?"-"?&?mid(Value,5,2)?&?"-"?&?right(Value,2)
????end?if
????if?isDate(nowDates)=true?then
????????FormatValue?=?Value
????else
????????FormatValue?=?""
????end?if
End?Function
</SCRIPT>
<HTML>
<BODY>
<b>判斷數(shù)字的正確性</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>數(shù)字</B></TD>
<TD><%=isNumeric(strTemp)%></TD>
</TR>
<TR>
<TD ALIGN="right"><B>非負數(shù)字</B></TD>
<TD><%=isUnsignedNumeric(strTemp)%></TD>
</TR>
<TR>
<TD ALIGN="right"><B>整數(shù)</B></TD>
<TD><%=isInteger(strTemp)%></TD>
</TR>
<TR>
<TD ALIGN="right"><B>非負整數(shù)()</B></TD>
<TD><%=isUnsignedInteger(strTemp)%></TD>
</TR>
</TABLE>
<FORM ACTION="<%=Request.ServerVariables("SCRIPT_NAME")%>" METHOD="post">
請輸入一個數(shù)字:<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
《新程序員》:云原生和全面數(shù)字化實踐50位技術專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的isNumeric isInteger isDate的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SharePoint 2013 - Ca
- 下一篇: bootstrap 模态窗口 多重/多个