Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General > Java

Notices


Reply
 
Thread Tools Rate Thread Display Modes
Old 09-28-2011, 11:41 PM   #1
ncjbhd
Registered User
 
Join Date: Jul 2011
Posts: 262
Check size of input

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
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
ncjbhd is offline   Reply With Quote

Old 10-10-2011, 10:08 PM   #2
Spoint_Vinil
Moderator
 
Join Date: Sep 2011
Location: INDIA
Posts: 250
use text.length property
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Spoint_Vinil is offline   Reply With Quote
Old 10-22-2011, 01:25 AM   #3
a.oprea
Registered User
 
Join Date: Jul 2011
Posts: 49
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String x;
System.out.print("Input text -> ");
x = scan.nextLine();
while(x.length() < 3 || x.length() >20) {
System.out.print("Word length must be between 3 and 20 -> ");
x = scan.nextLine();
}
System.out.println("Text length: " + x.length());
}

Something like this i asume?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
a.oprea is offline   Reply With Quote
Old 12-07-2011, 11:36 PM   #4
leonidasbourne
Registered User
 
Join Date: Nov 2011
Posts: 48
You have to check variable length or textbox character length right, than you get text from text box and store it in variable and check its length properties, easily you will find out length of text.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
leonidasbourne is offline   Reply With Quote
Old 02-22-2012, 04:47 AM   #5
madhuriarora
Registered User
 
Join Date: Dec 2011
Posts: 217
We can check the length of the input easily be using some syntax like
text.length.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
madhuriarora is offline   Reply With Quote
Old 05-21-2012, 05:59 AM   #6
seo123
Registered User
 
Join Date: Sep 2011
Posts: 113
hey i agree with you my friend.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
seo123 is offline   Reply With Quote
Old 02-26-2014, 03:10 AM   #7
alligatortek001
Registered User
 
Join Date: Nov 2013
Posts: 92
Quote:
Originally Posted by ncjbhd View Post
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
You may use the "text.length" property
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
alligatortek001 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:53 PM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.