|
function isEmpty(s) {
var valid = /\S+/.test(s);
return !valid;
}
This pattern of validation is not really adequate as any non-whitespace character, even a digit or a ? will return false, that is pass the validation. A proper name may only contain letters, hyphen, space and apostrophe. This topic has been covered many times before in this forum.
As AndrewGSW says, avoid assigning the same name to an HTML elemnt and a Javascript variable.
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Last edited by Philip M; 10-07-2012 at 10:32 AM..
|