Re: Limiting Punctuation Characters In Code
Re: Limiting Punctuation Characters In Code
- Subject: Re: Limiting Punctuation Characters In Code
- From: Seejo Pylappan <email@hidden>
- Date: Wed, 5 Feb 2003 09:10:53 -0500
Change the condition to be :
if ((!Character.isLetter(c)) || ((!Character.isLetter(c)) && (c !=
'-')))
On Wednesday, February 5, 2003, at 07:44 AM, Jonathan Fleming wrote:
You'll all probably think I'm dippy, and I would be if I didn't ask.
The bit of code below tests if a name is not null and valid and
doesn't allow any puctuation in it, however, i would like the user to
be able to use a hypen (dash -) in their name if they have a double
fist name like "Lesley-Ann" or "Mary-Lee"... This would be the only
puctuation mark they can use in a name but I am having trouble writing
this into the code basically because I don't know how and I'm wasting
time muddling about with it. Can anyone help please.
Many thanks
Jonathan
Here's the code:
/**
* Test if name is valid
**/
public String isValidName(String value)
{
String msg = null;
if (value!=null)
{
for (int index=0; index<value.length(); index++)
{
char c = value.charAt(index);
if (!Character.isLetter(c))
{
msg = "The value \"" + value + "\" is not a valid
name. Avoid numbers and punctuation. Try something like \"Mary\"";
break;
}
}
}
else
{
msg = "A valid name is required. Avoid numbers and
punctuation. Try something like \"Mary\"";
}
return (msg);
}
_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://messenger.msn.co.uk
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.