在ASP中如何判断提交的表单是不是数字,急!!!
我写了下面这一段代码,如何判断购买的数量(表单)不是数字:<html><head><title>订票</title></head><bodybgcolor="yellow...
我写了下面这一段代码,如何判断购买的数量(表单)不是数字:
<html>
<head><title>订票</title></head>
<body bgcolor="yellow" background="banner.jpg" topmargin="1">
<table border="0" cellspacing="0" style="border-collapse: collapse; border-left-style: solid; border-left-width: 1; border-right-style: solid; border-right-width: 1; border-top-width: 1; border-bottom-width: 1; border-top-style:solid" bordercolor="#006D91" width="496" bgcolor="#EFEFEF" align="center" height="1">
<%=now%>
<%
dim var_name
var_name=request.form("input_name")
dim var_num
var_num=request.form("input_num")
dim var_train_num
var_train_num=request.form("buy_num")
'response.write"" & var_num1 &""
dim Conn
Set Conn=Server.CreateObject("ADODB.Connection")
dim Strconn
Strconn="Driver={SQL Server};Server=10.1.40.110;Uid=teacher;Pwd=123;DataBase=test"
Conn.open Strconn
sql="insert into total_info(train_number,ticketnum,buyer)values('" & var_train_num & "','"& var_num &"','" & var_name & "')"
dim a
Conn.execute sql,a
if a=1 then
response.write "订票成功!"
else
response.write "更新失败!"
end if
%> 展开
<html>
<head><title>订票</title></head>
<body bgcolor="yellow" background="banner.jpg" topmargin="1">
<table border="0" cellspacing="0" style="border-collapse: collapse; border-left-style: solid; border-left-width: 1; border-right-style: solid; border-right-width: 1; border-top-width: 1; border-bottom-width: 1; border-top-style:solid" bordercolor="#006D91" width="496" bgcolor="#EFEFEF" align="center" height="1">
<%=now%>
<%
dim var_name
var_name=request.form("input_name")
dim var_num
var_num=request.form("input_num")
dim var_train_num
var_train_num=request.form("buy_num")
'response.write"" & var_num1 &""
dim Conn
Set Conn=Server.CreateObject("ADODB.Connection")
dim Strconn
Strconn="Driver={SQL Server};Server=10.1.40.110;Uid=teacher;Pwd=123;DataBase=test"
Conn.open Strconn
sql="insert into total_info(train_number,ticketnum,buyer)values('" & var_train_num & "','"& var_num &"','" & var_name & "')"
dim a
Conn.execute sql,a
if a=1 then
response.write "订票成功!"
else
response.write "更新失败!"
end if
%> 展开
展开全部
判断数据是否为数字使用:
if not isnumeric(var_num) then
response.Write "不是数字格式"
end if
if not isnumeric(var_train_num) then
Response.Write "不是数字"
end if
发现你后边的SQL语句好像有问题
sql="insert into total_info(train_number,ticketnum,buyer)values('" & var_train_num & "','"& var_num &"','" & var_name & "')"
ticketnum字段是文本格式?
数字字段写入数据库两边不要有'
文本格式才是'"&aaa&"'
数字格式是: "&aaa&"
if not isnumeric(var_num) then
response.Write "不是数字格式"
end if
if not isnumeric(var_train_num) then
Response.Write "不是数字"
end if
发现你后边的SQL语句好像有问题
sql="insert into total_info(train_number,ticketnum,buyer)values('" & var_train_num & "','"& var_num &"','" & var_name & "')"
ticketnum字段是文本格式?
数字字段写入数据库两边不要有'
文本格式才是'"&aaa&"'
数字格式是: "&aaa&"
展开全部
在客户端做判断,用正则表达式
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
dim var_num
var_num=request.form("input_num")
if not isnumeric( var_num ) then
response.write "不是数字"
end if
var_num=request.form("input_num")
if not isnumeric( var_num ) then
response.write "不是数字"
end if
参考资料: http://baike.baidu.com/view/1229896.htm
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询