Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 1,693
Trades: 0
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
 
 
Register now for full access!
Old 03-29-2005, 09:22 AM
pitbull82's Avatar
Super Talker

Posts: 147
Name: Marcin Nabiałek
Location: Poland, Częstochowa
Trades: 0
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>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
pitbull82 is offline
Reply With Quote
View Public Profile Visit pitbull82's homepage!
 
Old 03-29-2005, 09:28 AM
Unknown.

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.10939 seconds with 12 queries