Reply
Check size of input
Old 03-29-2005, 07:33 AM Check size of input
Unknown.

Posts: 1,693
How would i go about checking the length of the input the user has put into a text field...

What I want to be able to do is check if what they have entered is between 3 and 20 characters long.. then if its less than 3 or more than 20 use an alert to tell them they must enter a username between 3 and 20 characters.

Thanks
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 03-29-2005, 08:22 AM
pitbull82's Avatar
Super Talker

Posts: 147
Name: Marcin Nabiałek
Location: Poland, Częstochowa
Here's your code:

Code:
<html>
<head>
<script type="text/javascript">
function check(what)
{
	var length=what.nickname.value.length;	

	if (length >2 && length < 21)
		what.submit();
	else
		alert("Your nick should be 3-20 characters long.");
}
</script>
</head>
<body>
<form action="sendMessage.php" method="post">
<div>
<input type="text" value="" name="nickname"  />
<input type="submit" value="Submit" onclick="check(this.form); return false;" />
</div>
</form>
</body>
</html>
__________________
Seo Link Directory | Kurs C++ | Forum C++
pitbull82 is offline
Reply With Quote
View Public Profile Visit pitbull82's homepage!
 
Old 03-29-2005, 08:28 AM
Unknown.

Posts: 1,693
Thanks
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Check size of input
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14059 seconds with 12 queries