下面帮助中的一个例子,
当我复制代码测试时,无论怎样输入,都会一直提示“请完整输入订单内容”
valid.htm
网页中判断有无输入的判断语句 e.PostValues.ContainsKey("产品") 结果一直显示为假,始终无法接收到已经输入的“产品”取值,另外两个也是一样的
请问问题出现在哪里,怎样才能实现既能收到输入结果,又能动态显示提示输入错误呢?
再谈表单验证
设计步骤
1、在"d:\web"目录下,建立一个子目录lib,在这个目录建立一个文本文件,文件名为"ajaxform.js",文件内容为:
function
validit(){
var
result=submitAjaxFileds("valid.htm","","产品","数量","折扣",false);
if(result=="OK"){
return true;
}
else{
showTopTips("toptip1",result,2500);
return
false;
}
}
2、HttpRequest事件代码:
Select
Case e.Path
Case
"addnew.htm"
If e.PostValues.Count
= 0
Then
Dim wb As New weui
wb.AddTopTips("","toptip1","") '用于显示动态错误提示
wb.AddForm("","form1","addnew.htm").Attribute=""
With wb.AddInputGroup("form1","ipg1","新增订单")
.AddSelect("产品","产品","|PD01|PD02|PD03")
.AddInput("数量","数量","number")
.AddInput("单价","单价","number").Step = 0.1
.AddInput("折扣","折扣","number").Step = 0.01
With .AddUploader("up1","图片",True)
.TextPosition = 0
'标题靠左
.AddImage("./images/shuqi2.jpg")
End
With
End
With
With wb.AddButtonGroup("form1","btg1",True)
.Add("btn1",
"确定","submit")
End
With
wb.AppendHTML("<script
src='./lib/ajaxform.js'></script>") '引入脚本文件
e.WriteString(wb.Build)
Else
Dim sb As New StringBuilder
sb.AppendLine("<meta
name='viewport'
c>")
sb.AppendLine("我已经收到您提交的数据和文件")
e.WriteString(sb.Tostring)
End
If
Case
"valid.htm"
If e.PostValues.ContainsKey("产品") AndAlso e.PostValues.ContainsKey("数量") AndAlso e.PostValues.ContainsKey("折扣") Then
If e.PostValues("产品") =
"PD01"
AndAlso e.PostValues("数量")
> 1000
Then
e.WriteString("PD01库存只剩1000啦!")
ElseIf e.PostValues("产品") =
"PD01"
AndAlso e.PostValues("折扣")
> 0.1
Then
e.WriteString("PD01的最大允许折扣为0.1哦")
Else
e.WriteString("OK")
End
If
Else
e.WriteString("请完整输入订单内容!")
End
If
End
Select
[此贴子已经被作者于2024/9/4 0:21:50编辑过]