佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 736|回复: 9

询问ASP validation code for 检查space, character

[复制链接]
发表于 18-4-2006 05:03 PM | 显示全部楼层 |阅读模式
想问下如果我要检查user key in的data有没有space要怎样写?
我这样写, 可是失败了!If Space(request.form("txtpassword"))>1 then xxxxxxxxxxxxxxxxxxxxxxxxx


还有就是怎样确保user key in的data全部是数字没有character?
回复

使用道具 举报


ADVERTISEMENT

发表于 18-4-2006 06:46 PM | 显示全部楼层
试下这个

If instr(yourtextbox.text, " ") Then
...................
...................
End If

Validate Numeric:
If Not IsNumeric(yourtextbox.text) Then

.............
............

End if


[ 本帖最后由 Mr^MOon 于 18-4-2006 06:48 PM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 25-4-2006 08:07 AM | 显示全部楼层
谢谢我迟一点会试那个check space的。
那个确保全部是数字的, 我已经用java script代替了

if number(A)
response.write "Thank you"
回复

使用道具 举报

发表于 25-4-2006 01:17 PM | 显示全部楼层
没有记错的话,可以用 trim() ....用法怎样我忘记了, 可是上网找一下应该有的
回复

使用道具 举报

发表于 25-4-2006 02:35 PM | 显示全部楼层
请问一下,怎样做以下的
如果有两个input text
都没有fill in details
submit之前
会pop up 1 message box alert " please fill in at least 1 of the field"
回复

使用道具 举报

发表于 25-4-2006 03:00 PM | 显示全部楼层
这个药用javascript了。


  1. <HTML>
  2. <HEAD>
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4. <TITLE>Check Form</TITLE>
  5. </HEAD>
  6. <SCRIPT LANGUAGE="JavaScript">
  7. function test(form)
  8. {
  9. if(document.myform.name.value=="")
  10. {
  11. alert("Please Fill In Name!")
  12. document.myform.name.focus()
  13. return false
  14. }
  15. else if (document.myform.email.value=="")
  16. {
  17. alert("Please Fill In Email!")
  18. document.myform.email.focus()
  19. return false
  20. }
  21. else if (document.myform.address.value=="")
  22. {
  23. alert("Please Fill In Address")
  24. document.myform.address.focus()
  25. return false
  26. }
  27. return true
  28. }
  29. </SCRIPT>

  30. <BODY bgcolor="#3399FF">
  31. <table border="1" width="600" bordercolorlight="#000080" bordercolor="#00FFFF" cellspacing="0">
  32. <tr>
  33. <td width="100%" bordercolorlight="#000000">
  34. <form name="myform" method="POST" action="Success" onSubmit="return test(this)">
  35. <div align="center">
  36. <center>
  37. <table border="0" width="500" height="220" cellspacing="0" cellpadding="0" bgcolor="#004EC3">
  38. <tr>
  39. <td width="457"><font color="#FFFFFF">Name
  40. <input type="text" name="name" size="24"></font></td>
  41. </tr>
  42. <tr>
  43. <td width="457"><font color="#FFFFFF">E-Mail?
  44. <input type="text" name="email" size="23"></font></td>
  45. </tr>
  46. <tr>
  47. <td width="457"><font color="#FFFFFF">Address<input type="text" name="address" size="56"></font></td>
  48. </tr>
  49. <tr>
  50. <td width="457">
  51. <input type="submit" value="Submit" name="submit">
  52. <input type="reset" value="Reset" name="Reset"></td>
  53. </tr>
  54. </table>
  55. </center>
  56. </div>
  57. </form>
  58. </td>
  59. </tr>
  60. </table>
  61. </BODY>
  62. </HTML>
复制代码


收好不要不见
回复

使用道具 举报

Follow Us
welstein 该用户已被删除
发表于 25-4-2006 03:01 PM | 显示全部楼层
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Alert Message</TITLE>
<SCRIPT TYPE="text/javascript">
        function onSubmit(){
                var strName = document.getElementById('txtName').value;
                var strPassword = document.getElementById('txtPassword').value;
                if(strName == "" || strPassword == ""){
                        alert("Error~")
                }
        }
</SCRIPT>
</HEAD>

<BODY>
<FORM name="frmLogin" id="frmLogin">
<INPUT TYPE="text" name="txtName" id="txtName" />
<INPUT TYPE="text" name="txtPassword" id="txtPassword" />
<INPUT TYPE="button" onClick="onSubmit()" value="Validate">
</FORM>
</BODY>
</HTML>
回复

使用道具 举报

welstein 该用户已被删除
发表于 25-4-2006 03:03 PM | 显示全部楼层
红发的coding比较好,哈哈~搂主可以参考他的。我的coding就有点懒惰~ ^^
回复

使用道具 举报


ADVERTISEMENT

发表于 25-4-2006 03:50 PM | 显示全部楼层
红发
你的coding
是每一个field都要填,不是吗?
我要的是
当两个field都没有填东西的时候
就要alert user " pls fill in 1 of the field "
如果其中一个填了就可以submit到
回复

使用道具 举报

 楼主| 发表于 26-4-2006 09:44 AM | 显示全部楼层
trim只可以用来check开头和结尾有没有space,  不可以check两个string中间的space. 嘿嘿
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 10-3-2025 05:42 AM , Processed in 0.108987 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表