ASP检查字符串格式是否匹配问题!
问题1.
-----------------------------------------------------------
ASP验证表单中提交的变量是否为ip格式
如 127.0.0.1
检查2项
1. 不能有其他字符 只能是数字 0~9 符号 .
2. 字符长度不能超过 20
然后用 tirm()去掉空格
问题2.
-------------------------------------------------------------
输入的为时间格式
年4位 横杠 月2位 横杠 日2位 空格 时2位 冒号 分2位 冒号 秒2位
如:2009-12-24 23:59:59
检查2项
1.全部为数字
2.年月日中间是否有横杠
3.时分秒中间是否有冒号
4.年月日 与 时分秒 中间是否有空格
1.
HTML code:
<%
function check(str)
dim reg
set reg = New RegExp
reg.Global=true
reg.Pattern="^(\d+?\.\d+?\.\d+?\.\d+?)$"
reg.IgnoreCase = false
str=trim(str)
if len(str)>20 then
check=false
response.write "长度超过20!"
elseif reg.Execute(str).count = 0 then
response.write "ip格式不匹配!"
else
response.write "ip格式匹配!"
end if
end function
dim str
str="127.000000a.0.1"
call check(str)
%>
一种用正则,一种字符串操作,你看看哪种适合你
给你个字符串的例子
VBScript code
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.Cod
相关问答:
在asp里怎么调用java写的webservice方法,有很多方法
- <message name="RtPnrIn">
<part name="bstrPnrNO" type="s:string" />
<part name ......
本人不会asp,报错了,请大家帮忙看看。
代码如下:
<%
dim keyword_Name,keyword_YJ,keyword_RQ
if rs("QS_PASS_1_name")<>"0,0" then
keyword_Name=split(rs("QS_ ......
A页面
<table width="200" border="1">
<tr>
<td>1</td>
<td>3</td>
<td><!--#include/top.html#-- ......
<?xml version="1.0"?>
<root>
<status>433</status>
<msg>这个是汉字</msg>
<serialno>123</serialno>
</root>
如何用ASP读取 status值 ......