String Validation


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. String x = "LLL 00 LLL";
  2.  
  3. if ( x.length()==9
  4. && java.lang.Character.isLetter(x.charAt(0))
  5. && java.lang.Character.isLetter(x.charAt(1))
  6. && java.lang.Character.isLetter(x.charAt(2))
  7. && java.lang.Character.isSpace (x.charAt(3))
  8. && java.lang.Character.isDigit (x.charAt(4))
  9. && java.lang.Character.isDigit (x.charAt(5))
  10. && java.lang.Character.isSpace (x.charAt(6))
  11. && java.lang.Character.isLetter(x.charAt(7))
  12. && java.lang.Character.isLetter(x.charAt(8))
  13. && java.lang.Character.isLetter(x.charAt(9)))
  14. {
  15. // do something for match
  16. }
  17. else {
  18. // do something for not match
  19. }

URL: http://www.thescripts.com/forum/thread17738.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.