Showing posts with label how to validate empty spaces in javascript. Show all posts
Showing posts with label how to validate empty spaces in javascript. Show all posts

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;
}