Click to See Complete Forum and Search --> : Help filtering this
zer0_flaw
Oct 26th, 2001, 09:36 AM
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>
PunkRockNeil
Oct 26th, 2001, 10:30 AM
The following section of Javascript/HTML should do the job for you.
<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>
JoshT
Oct 26th, 2001, 10:41 AM
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...
sail3005
Oct 26th, 2001, 03:34 PM
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!
rjlohan
Oct 28th, 2001, 09:06 PM
<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??
JoshT
Oct 29th, 2001, 11:57 AM
maxlength=50 should limit the number of characters a user can type into the box. It's by no means secure, though.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.