0

How can i validate an emailAddressfield in blackberry?

Thanks in advance, I'm a bit stuck.

Mat
  • 202,337
  • 40
  • 393
  • 406
zoya.
  • 51
  • 1
  • 8

2 Answers2

0

If we are talking about Java Microedition basic validation is possible through TextField constrain parameter as TextField.EMAILADDR

Example TextField("Email", "", 100, TextField.EMAILADDR) However I would be wary of this as does check only for basic stuff

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
peter_budo
  • 1,748
  • 4
  • 26
  • 48
0

Validating EMail addresses (format wise) is very hard, so hard, that one may consider to just don't do it. The recommendation is, at least, to not do it yourself but try to get a library for that task.

Here's a good article on SO about this topic.

Community
  • 1
  • 1
Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268
  • hello frens,,,,thanks for replyin ... i got the solution using this...... public boolean isDataValid(String mail) { // String address = getText(); int at = mail.indexOf("@"); int len = mail.length(); if (at <= 0 || at > len - 6) return false; String host = mail.substring(at + 1, len); len = host.length(); if (host.indexOf("..") >= 0) return false; int dot = host.indexOf("."); return (dot > 0 && dot <= len - 3); } – zoya. Apr 20 '11 at 05:26