samedi 28 février 2015

How to validate that a string from a textbox contains only 2 characters and 3 numbers?

I have checked other answers and am not finding what I need to know. I have a variable named nationalID which can only contain 2 characters and 3 numbers (ex. aa123) How do I say this in java? I am using Netbeans and have looked at all of the methods that pops up but I am not seeing anything that will help me. This is what I have so far.



private String validator(String nationalID, String lastName, String firstName, String dateOfBirth) {
// nationalID should have 2 characters and 3 digits ex. AB123
// dateOfBirth should be yyyy-mm-dd

if(nationalID.length() != 5 || nationalID.){
String err;
return err = "Your National ID has to be 5 characters long";
}

return "";
}




Aucun commentaire:

Enregistrer un commentaire