File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Validations for name in text only" Watch "Validations for name in text only" New topic
Author

Validations for name in text only

Sonali Sharma
Greenhorn

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
Greenhorn

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.

eg:
String s="Hello";
if(s.length()>=23){
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
Marshal

Joined: Jan 10, 2002
Posts: 61589
    
  67

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validations for name in text only