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...
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.
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...
...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.
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...
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.
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.
Bookmarks