B1
if (this.id === 'username') {
switch (this.value.length) {
case 0:
case 1:
case 2:
// 'Username must be at least 3 characters'
break;
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
// Another if else statement
break;
default:
// 'Username must be at most 20 character'
}
}
B2
if (this.id === 'username') {
if (this.value.length < 3) {
// 'Username must be at least 3 characters'
} else if (this.value.length > 20) {
// 'Username must be at most 20 characters'
} else {
// Another if else statement
}
}
I would test this myself using browser developer tools, but unfortunately I'm a n00b to programming, and don't yet know how to use the developer tools all that well. Any input would be greatly appreciated.