|
-
Oct 26th, 2001, 09:36 AM
#1
Thread Starter
Hyperactive Member
Help filtering this
This makes two boxes that users of the site can type into and submit. One is labeled "Nick" and the other is "Comment". My question is how do I limit it so the nick cannot be "bleh" and the comment can be no longer then 50 letters. Any help is GREATLY appreciated. Thanks in advance... here's the code:
<form method="POST" action=addpost.php>Nick: <div align=center><input class=inputsb type=text name=n value=""></td></tr>
<tr><td class=sbcomment>Comment: <div align=center><input type=text name=c limit=50 class=inputsb></td></tr>
<tr><td class=sbcomment align=center>HTML is off.</td></tr><tr><td class=sbcomment><div align=center><input type=submit value=Submit class=inputsb></form>
-
Oct 26th, 2001, 10:30 AM
#2
Lively Member
The following section of Javascript/HTML should do the job for you.
Code:
<HTML>
<HEAD>
<script language="javascript">
function checkForm(){
if (document.frmPost.n.value != "bleh"){
document.frmPost.submit();
}
else {
alert('Sorry Nick can not equal bleh');
}
}
</script>
</HEAD>
<BODY>
<form method="POST" action="addpost.php" name="frmPost">
<table>
<tr>
<td>
Nick:
<input class="inputsb" type="text" name="n" value="">
</td>
</tr>
<tr>
<td class="sbcomment">
Comment:
<input type="text" name="c" size="50" class="inputsb>
</td>
</tr>
<tr>
<td class="sbcomment" align="center">
<input type="button" onclick="checkForm()">Submit</input>
</td>
</tr>
</table>
</form>
</body>
</HTML>
-
Oct 26th, 2001, 10:41 AM
#3
Black Cat
This makes two boxes that users of the site can type into and submit. One is labeled "Nick" and the other is "Comment". My question is how do I limit it so the nick cannot be "bleh" and the comment can be no longer then 50 letters. Any help is GREATLY appreciated. Thanks in advance... here's the code:
You really need to validate this on the server, too, though...
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Oct 26th, 2001, 03:34 PM
#4
PowerPoster
yeah, i say always validate it on the server. anyone can get around it otherwise. just look at what happened on this site with the custom statuses!
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Oct 28th, 2001, 10:06 PM
#5
PowerPoster
Two things...
<input type="text" name="c" size="50" class="inputsb>
From Neil
I juist wanted someone to verify that setting the size attribute of a text-box actually limits the input length? I was under the impression that this merely limited the viewable area. Am I mistaken? And is this the same for NS & IE??
The other - zer0, did you want to specifically prevent 'bleh' as an input, or were you looking to prevent a garbage entry??
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Oct 29th, 2001, 12:57 PM
#6
Black Cat
maxlength=50 should limit the number of characters a user can type into the box. It's by no means secure, though.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|