This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Validations for name in text only Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Validations for name in text only" Watch "Validations for name in text only" New topic

Validations for name in text only

Sonali Sharma

Joined: Nov 24, 2011
Posts: 1
Hello i want to have the validation o the name so that it must be text and less than 26 characters.What coding i have to do and where i have to put this coding?

Astrology in Delhi | Corporate Event Management | Seo Services Delhi
Debajyoti Kundu

Joined: Sep 14, 2011
Posts: 23
Hi Sonali,
Is this validation is for value of some text box of a html page or for a String variable in java?

If it's html then you need javascript.

If it's java code then use a loop and check ASCII value of each character comes under 65-90 or 97-122(for A-Z and a-z). Keep this loop inside a if block which will check it's length.

String s="Hello";
for(int i=0;i<s.length;i++)
int ch=(int)s.charAt(i);
// now check value of ch to find if the string contains any thing other that characters or not. you and add the range of numerical digits in condition checking if you want those
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60810

A regular expression would be a quicker and easier way to check for a pattern match.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
wood burning stoves
subject: Validations for name in text only
Similar Threads
how to match the regular expression using if
On blur to be automactially called
In java pattern matching how do declare string
how to save jsp report to the text file
generating dynamic xml with java