I have an input form which needs to be validated in real time (.Keyup and .Load)
It should allow all A-z characters (Upper & lower) and the symbols "'", "-" and " " (apostrophe, dash and whitespace).
At the moment this is what I have: ([A-Za-z]-\s\')* and I'm using it like this:
var regex = /([A-Za-z]\-\s\')*/;
if (string == "") {
turn textbox border grey (default)
} else if (!regex.test(string)) {
turn textbox border red
} else {
turn textbox border green
}
All it does it change the the textbox green every time (Unless it's blank - it goes grey). What's the correct expression/technique and what am I doing wrong?
---------or''''''''''''''''are valid input? Can't you narrow that down to edge conditions of some type of actual final validation?