Code:
if (input.length >= 6 && input.length<=10){
return true
}else {
alert("The field must contain 6 character or 10 character!")
return false;
}
Meaning of code:
if the input length is between 6 and 10 both inclusive then do this.
else if it is less than 6 (not including 6) or greater than 10 (not including 10) do this.
Or if you want something like this
Code:
if (input.length >= 6 && input.length<=10){
return true
}else if(input.length < 6){
alert("The field is too short must contain at least 6 character!")
return false;
}else{
alert("The field is too long must contain no more than 10 character!")
return false;
}
Bookmarks