-
June 16th, 2008, 01:02 AM
#1
textfield validation
hi,I want to know how cani validate textfield by checking whether there is entry in textfield..,if there is,how to determine whether its valid entry or not...thanq u... was lukin thru api,but it does not seem to do any help....atleast i am not sure whether im looking for anwer at correct place...f sme1 can help me...,t will do betr...
-
June 16th, 2008, 04:26 AM
#2
Re: textfield validation
What would you consider to be a valid textfield entry?
-
June 16th, 2008, 04:33 AM
#3
Re: textfield validation
If you want to check whether there is an entry in a text field, just call getText() on it - this will return you the contents for checking. If there is no entry, you should get back an empty String (length 0). It's up to you to decide what a valid entry is, so without more information I can't help you with that.
Incidentally, your keyboard seems to be playing up - some keys don't appear to be working all the time.
Imagination is more important than knowledge...
A. Einstein
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
June 16th, 2008, 06:00 AM
#4
Re: textfield validation
sorry,I dint make it clear in the first place...what i want to do is to check whether the particular textfield is empty or not..If the textfield is nonempty,I have to check whether the user has inputted the textfiled with the proper text....thanx in advance...
-
June 16th, 2008, 08:05 AM
#5
Re: textfield validation
Originally Posted by fairyland121
...what i want to do is to check whether the particular textfield is empty or not..If the textfield is nonempty,I have to check whether the user has inputted the textfiled with the proper text...
I just told you that - textfield.getText() will return the contents as a String. If string.length() returns zero the text field was empty. If not, you can validate the contents of the string.
If that doesn't answer your question, or you don't understand something, please explain.
If you can't explain it simply, you don't understand it well enough...
A. Einstein
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
June 17th, 2008, 07:00 AM
#6
Re: textfield validation
thanx 4 the help...its working now... I want to know if i can check for alphanumeric characters or special characters in textfiled where i have to write text...
-
June 17th, 2008, 07:13 AM
#7
Re: textfield validation
If you want to check individual characters to see if they are letters, digits, whitespace, control characters etc you can convert the string to a char array using the toCharArray() method and then test each character using the methods in the Character class such as Character.isLetter(ch), Character.isLetterOrDigit(ch), Character.isDigit(ch), Character.isWhiteSpace(ch) etc.
-
June 17th, 2008, 07:48 AM
#8
Re: textfield validation
Originally Posted by keang
If you want to check individual characters to see if they are letters, digits, whitespace, control characters etc you can convert the string to a char array using the toCharArray() method...
Alternatively, you can access them directly from the string using the String.charAt(index) method, e.g. Character.isDigit(myString.charAt(0)).
Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration...
S. Kelly-Bootle
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|