Ady Wicaksono Daily Activities

verify blank string on form with javascript

leave a comment »

Here’s the function

function isSpaceOnly(s){
var l = s.length;
var c; for(i = 0; i < l; i++){
   if(s.charAt(i) != ' ' && s.charAt(i) != '\t' && s.charAt(i) != '\n'){
      return false;
   }
 }
 return true;
}

Then you only need to use if that function return true -> meaning blank string including space only string given

Written by adywicaksono

October 31, 2007 at 2:18 pm

Posted in javascript

Leave a Reply