I have a multilingual website (Chinese and English).
I like to validate a text field (name field) in javascript. I have the following code so far.
var c
var chkName = /\s/;
function check(name) {
document.write("
" + name + " is ");
if (!chkName.test(name)) {
document.write("okay");
} else {
document.write("invalid");
}
}
check("namevaluegoeshere");
check("name value goes here");
This way you just check if there's any white space in the name.
demo @ http://jsfiddle.net/roberkules/U3q5W/