Site Owners Forums - Webmaster Forums

Site Owners Forums - Webmaster Forums (http://siteownersforums.com/index.php)
-   Java (http://siteownersforums.com/forumdisplay.php?f=12)
-   -   Check size of input (http://siteownersforums.com/showthread.php?t=51462)

ncjbhd 09-28-2011 11:41 PM

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

Spoint_Vinil 10-10-2011 10:08 PM

use text.length property

a.oprea 10-22-2011 01:25 AM

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?

leonidasbourne 12-07-2011 11:36 PM

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.

madhuriarora 02-22-2012 04:47 AM

We can check the length of the input easily be using some syntax like
text.length.

seo123 05-21-2012 05:59 AM

hey i agree with you my friend.

alligatortek001 02-26-2014 03:10 AM

Quote:

Originally Posted by ncjbhd (Post 177319)
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


All times are GMT -7. The time now is 03:13 PM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.