以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 移动开发,多个按键判断输入值是否有效 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=109027) |
-- 作者:qwz405 -- 发布时间:2017/11/2 21:08:00 -- 移动开发,多个按键判断输入值是否有效 如下所示代码,有2个或以上按键时,如果判断输入值的是否有效,并进行下一步。(下面的代码,能判断输入值并作出提示,当输入值有效时不能继续下去) .... If e.PostValues.Count = 0 Then Dim dr As DataRow = DataTables("设备点检").SQLFind("[编号]= \'"& str2 &"\'") If dr IsNot Nothing Then wb.AddTopTips("","toptip1","未按要求填写数据!") \'用于显示动态错误提示 wb.AddForm("","form1","./bb.htm?tp=" & tp & "&str=" & str) With wb.AddInputGroup("form1","ipg1","设备名称") With .AddTextArea("设备名称",1) .Value = dr("设备名称") .Readonly = True End With End With With wb.AddInputGroup("form1","ipg2","编号") With .AddTextArea("编号",1) .Value = dr("编号") .Readonly = True End With End With If tp2 = "ysj" With wb.AddInputGroup("form1","ipg10","点检项目(必填)") .AddSelect("txt1","周边环境","|正常|异常") End With With wb.AddButtonGroup("form1","btg1",False) With .Add("btn1","存档1","button") .Kind = 2 .Attribute= "o n click=\'getcheck1()\'" \'调用js函数上传 End With .Add("btn4", "退出").Attribute = "o n c lick = ""WeixinJSBridge.call(\'closeWindow\')""" End With ElseIf tp2 = "kt" Then With wb.AddInputGroup("form1","ipg11","点检项目(必填)") .AddSelect("txt1","机台外观","|正常|异常") .AddSelect("txt2","面板功能","|正常|异常") End With With wb.AddButtonGroup("form1","btg1",False) With .Add("btn1","存档2","button") .Kind = 2 .Attribute= "o n click=\'getcheck2()\'" \'调用js函数上传 End With .Add("btn4", "退出").Attribute = "o n c lick = ""WeixinJSBridge.call(\'closeWindow\')""" End With End If End If wb.AppendHTML("<script src=\'./lib/check.js\'></script>") Else \'保存数据 ..... End If e.WriteString(wb.Build) \'生成网页 js代码如下所示: function getcheck1(){ var v1 = document.getElementById("txt1").value; if (v1){return true} show("toptip1",2500); //2500毫秒=2.5秒 return false; } function getcheck2(){ var v1 = document.getElementById("txt1").value; var v2 = document.getElementById("txt2").value; if (v1 && v2){return true} show("toptip1",2500); //2500毫秒=2.5秒 return false; } [此贴子已经被作者于2017/11/2 21:09:24编辑过]
|
-- 作者:有点甜 -- 发布时间:2017/11/2 23:19:00 -- 没看到你表达的意思,你要做什么功能?浏览器那里报什么错? |
-- 作者:qwz405 -- 发布时间:2017/11/3 8:30:00 -- 老师,早上好。 ... If e.PostValues.Count = 0 Then Dim dr As DataRow = DataTables("设备点检").SQLFind("[编号]= \'"& str2 &"\'") If dr IsNot Nothing Then wb.AddTopTips("","toptip1","未按要求填写数据!") \'用于显示动态错误提示 wb.AddForm("","form1","./bb.htm?tp=" & tp & "&str=" & str) ... If tp2 = "ysj" With wb.AddInputGroup("form1","ipg10","点检项目(必填)") .AddSelect("txt1","周边环境","|正常|异常") End With With wb.AddButtonGroup("form1","btg1",False) With .Add("btn1","存档1","button") --->调用js函数getcheck1,若txt1有值,则允许保存数据。 .Kind = 2 .Attribute= "o n click=\'getcheck1()\'" End With .Add("btn4", "退出").Attribute = "o n c lick = ""WeixinJSBridge.call(\'closeWindow\')""" End With ElseIf tp2 = "kt" Then With wb.AddInputGroup("form1","ipg11","点检项目(必填)") .AddSelect("txt1","机台外观","|正常|异常") .AddSelect("txt2","面板功能","|正常|异常") End With With wb.AddButtonGroup("form1","btg1",False) With .Add("btn1","存档2","button") --->调用js函数getcheck2,若txt1/txt2有值,则允许保存数据。 .Kind = 2 .Attribute= "o n click=\'getcheck2()\'" End With .Add("btn4", "退出").Attribute = "o n c lick = ""WeixinJSBridge.call(\'closeWindow\')""" End With End If End If wb.AppendHTML("<script src=\'./lib/check.js\'></script>") Else .....-->进入到这一步,保存传递过来的数据 End If e.WriteString(wb.Build) \'生成网页 如果我根据tp2值拆分多个网页,这样判断1个按键是否有效值,我用下面的代码,一直都可以的: 但如果tp2值多的话,就要重复写很多代码。 ... If e.PostValues.Count = 0 Then \'如果是首次登陆,生成用户留言网页 Dim dr As DataRow = DataTables("设备点检").SQLFind("[编号]= \'"& str2 &"\'") \'获得点检设备数据 If dr IsNot Nothing Then wb.AddTopTips("","toptip1","未按要求填写数据!") \'用于显示动态错误提示 wb.AddForm("","form1","./bb.htm?tp=" & tp & "&str=" & str).Attribute="o n submit = \'return getcheck1()\'" \'使用js脚本文件,判断是否按要求输入数据 ..... \'If tp2 = "ysj" With wb.AddInputGroup("form1","ipg10","点检项目(必填)") .AddSelect("txt1","周边环境","|正常|异常") End With With wb.AddButtonGroup("form1","btg1",False) .Add("btn1", "存档","submit").Kind = 2 .Add("btn4", "退出").Attribute = "o n click = ""WeixinJSBridge.call(\'closeWindow\')""" \'退出微信浏览器 End With \'ElseIf tp2 = "kt" Then \'With wb.AddInputGroup("form1","ipg10","点检项目(必填)") \' .AddSelect("txt1","机台外观","|正常|异常") \'.AddSelect("txt2","面板功能","|正常|异常") End With \'With wb.AddButtonGroup("form1","btg1",False) \' .Add("btn1", "存档","submit").Kind = 2 \' .Add("btn4", "退出").Attribute = "o n click = ""WeixinJSBridge.call(\'closeWindow\')""" \'退出微信浏览器 \' End With \' end if end if wb.AppendHTML("<script src=\'./lib/tl_check.js\'></script>") \'引入脚本文件 Else ... End If e.WriteString(wb.Build) \'生成网页 [此贴子已经被作者于2017/11/3 8:37:05编辑过]
|
-- 作者:有点甜 -- 发布时间:2017/11/3 8:49:00 -- 你要问的是如何判断值是否为空?
var v1 = document.getElementById("txt1").value;
[此贴子已经被作者于2017/11/3 8:49:24编辑过]
|
-- 作者:qwz405 -- 发布时间:2017/11/3 9:20:00 -- 老师,我是要实现这样的功能:根据上面代码的tp2值,会生成不同的页网,会有不同的数量的值要判断 比如 tp2 = "ysj" 时 With wb.AddInputGroup("form1","ipg10","点检项目(必填)") .AddSelect("txt1","周边环境","|正常|异常") End With 要判断txt1是否有效 如果 tp2 = "kt"时 With wb.AddInputGroup("form1","ipg10","点检项目(必填)") \'.AddSelect("txt1","机台外观","|正常|异常") .AddSelect("txt2","面板功能","|正常|异常") End With 要判断txt1/txt是否有效 又比如tp2=***时 With wb.AddInputGroup("form1","ipg10","点检项目(必填)") .AddSelect("txt1","周边环境","|正常|异常") .AddSelect("txt2","周边环境","|正常|异常") .AddSelect("txt3","周边环境","|正常|异常") End With 我可能只需要txt3一定有值,但txt1/txt2如果有值,就不能超过4个字符。。 等等。 [此贴子已经被作者于2017/11/3 9:20:07编辑过]
|
-- 作者:有点甜 -- 发布时间:2017/11/3 9:29:00 -- 既然是不同的页面,不同的判断,那就分开来比较,就好像你上面那样写多个函数分别判断。
你现在哪里无法实现?想怎样做? |
-- 作者:qwz405 -- 发布时间:2017/11/3 10:01:00 -- ... If e.PostValues.Count = 0 Then Dim dr As DataRow = DataTables("设备点检").SQLFind("[编号]= \'"& str2 &"\'") If dr IsNot Nothing Then wb.AddTopTips("","toptip1","未按要求填写数据!") \'用于显示动态错误提示 wb.AddForm("","form1","./bb.htm?tp=" & tp & "&str=" & str) ... If tp2 = "ysj" With wb.AddInputGroup("form1","ipg10","点检项目") .AddSelect("txt1","周边环境","|正常|异常") \'必填 End With With wb.AddButtonGroup("form1","btg1",False) With .Add("btn1","存档1","button") .Kind = 2 .Attribute= "o n click=\'return getcheck1()\'" --->调用js函数getcheck1,能判断输入值是否有效,但当输入有效时,不能跳转下页 End With End With ElseIf tp2 = "kt" Then With wb.AddInputGroup("form1","ipg11","点检项目") .AddSelect("txt1","机台外观","|正常|异常") \'选项,小于3字符 .AddSelect("txt2","面板功能","|正常|异常") \'必填 End With With wb.AddButtonGroup("form1","btg1",False) With .Add("btn1","存档2","button") .Kind = 2 .Attribute= "o n click=\'return getcheck2()\'" --->调用js函数getcheck2,能判断输入值是否有效,但当输入有效时,不能跳转下页 End With End With End If End If wb.AppendHTML("<script src=\'./lib/check.js\'></script>") Else ... End If e.WriteString(wb.Build) \'生成网页 js代码如下所示: function getcheck1(){ var v1 = document.getElementById("txt1").value; if (v1){return true} show("toptip1",2500); //2500毫秒=2.5秒 return false; } function getcheck2(){ var v1 = document.getElementById("txt1").value; var v2 = document.getElementById("txt2").value; if (v1.length < 3 && v2){return true} show("toptip1",2500); //2500毫秒=2.5秒 return false; } [此贴子已经被作者于2017/11/3 10:48:11编辑过]
|
-- 作者:qwz405 -- 发布时间:2017/11/3 10:54:00 -- 老师,提交按钮改成这样,测试可以提交数据了。。我先这样用,有问题再请教。。。 With wb.AddButtonGroup("form1","btg1",False) With .Add("btn1","存檔2","submit") .Kind = 2 .Attribute= "o n c lick=\'return getcheck1()\'" \'调用js函数上传 End With
[此贴子已经被作者于2017/11/3 10:54:54编辑过]
|