Sunday, July 24, 2011

Validate Empty spaces in Javascript

function checkSpaces(elm , fieldName){
var name = elm.value
name = name.replace(/(\s+)+/g," ");
if(name == "" || name == " "){
alert(fieldName +" should not allow empty spaces");
elm.focus();
return true;
}
return false;
}

No comments:

Post a Comment

Please comment on this