I need to do some verification on a 'title' text box in an html form. It needs to adhere to either Mr, Mrs, Miss etc.
I was going to use something like this...
if (Title.value != ("Mr" || "Mrs" || etc)){
alert("Invalid Title. Must be either Mr, Mrs, Ms, Miss, Dr, Prof, Rev, Sir, Lady, Lord"
;
return;
}
...but it's a bit messy and the boolean OR doesn't seem to work. Maybe i should put all the values in an array, and then do the validation on that?
Any help would be much appreciated.
Cheers
p.s. i can't use a drop down list due to data reasons
I was going to use something like this...
if (Title.value != ("Mr" || "Mrs" || etc)){
alert("Invalid Title. Must be either Mr, Mrs, Ms, Miss, Dr, Prof, Rev, Sir, Lady, Lord"
return;
}
...but it's a bit messy and the boolean OR doesn't seem to work. Maybe i should put all the values in an array, and then do the validation on that?
Any help would be much appreciated.
Cheers
p.s. i can't use a drop down list due to data reasons