I am applying certain conditions on data from 4 html fields, these fields are divided into two categories: category A (fields A1 and A2) and category B (fields B1 and B2)
N.B: I'm confused on how to achieve this with an elegant way
Rules:
1) When the 4 fields are empty, I return a message that the fields are empty.
2) When fields A1, A2 are valid and B1, B2 are empty I apply an action according to category A
3) rule exeption (2): When field A1 is valid and field A2 is empty, A2 assigns a value to A2 (e.g A2 = A1 ++)
4) When fields B1, B2 are valid and A1, A2 are empty I apply an action according to category B
5) exeption of rule (4): When field A1 is valid and field B2 is empty, B2 I assign a value to B2 (e.g B2 = B1 ++) 6) If all the fields are valid, I apply an action according to all the fields
if ( A1 == '' && A2 == '' && B1 == '' && B2 == '' ) {
System.out.println("empty fields");
}else if () {
} else {
}
Aucun commentaire:
Enregistrer un commentaire