查看: 736|回复: 9
|
询问ASP validation code for 检查space, character
[复制链接]
|
|
想问下如果我要检查user key in的data有没有space要怎样写?
我这样写, 可是失败了!If Space(request.form("txtpassword"))>1 then xxxxxxxxxxxxxxxxxxxxxxxxx
还有就是怎样确保user key in的data全部是数字没有character? |
|
|
|
|
|
|
|
发表于 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了。
- <HTML>
- <HEAD>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <TITLE>Check Form</TITLE>
- </HEAD>
- <SCRIPT LANGUAGE="JavaScript">
- function test(form)
- {
- if(document.myform.name.value=="")
- {
- alert("Please Fill In Name!")
- document.myform.name.focus()
- return false
- }
- else if (document.myform.email.value=="")
- {
- alert("Please Fill In Email!")
- document.myform.email.focus()
- return false
- }
- else if (document.myform.address.value=="")
- {
- alert("Please Fill In Address")
- document.myform.address.focus()
- return false
- }
- return true
- }
- </SCRIPT>
- <BODY bgcolor="#3399FF">
- <table border="1" width="600" bordercolorlight="#000080" bordercolor="#00FFFF" cellspacing="0">
- <tr>
- <td width="100%" bordercolorlight="#000000">
- <form name="myform" method="POST" action="Success" onSubmit="return test(this)">
- <div align="center">
- <center>
- <table border="0" width="500" height="220" cellspacing="0" cellpadding="0" bgcolor="#004EC3">
- <tr>
- <td width="457"><font color="#FFFFFF">Name
- <input type="text" name="name" size="24"></font></td>
- </tr>
- <tr>
- <td width="457"><font color="#FFFFFF">E-Mail?
- <input type="text" name="email" size="23"></font></td>
- </tr>
- <tr>
- <td width="457"><font color="#FFFFFF">Address<input type="text" name="address" size="56"></font></td>
- </tr>
- <tr>
- <td width="457">
- <input type="submit" value="Submit" name="submit">
- <input type="reset" value="Reset" name="Reset"></td>
- </tr>
- </table>
- </center>
- </div>
- </form>
- </td>
- </tr>
- </table>
- </BODY>
- </HTML>
复制代码
收好不要不见 |
|
|
|
|
|
|
|
发表于 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> |
|
|
|
|
|
|
|
发表于 25-4-2006 03:03 PM
|
显示全部楼层
红发的coding比较好,哈哈~搂主可以参考他的。我的coding就有点懒惰~ ^^ |
|
|
|
|
|
|
|
发表于 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. 嘿嘿 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|