javascript - How do I write a regex expression saying 'and NO whitespaces'? -


i wondering how write regex expression says 'and no whitespaces'.i need implement following if statement, see below:

$('#postcode').blur(function(){     var postcode = $(this), val = postcode.val();      if((val.length >= 5) && (*******)){         postcode.val(val.slice(0, -3)+' '+val.slice(-3)).css('border','1px solid #a5acb2');      }else{         $(this).css('border','1px solid red');      } }); 

any appreciated, thanks

try this:

&& (!val.match(/\s/)) 

match return null if there no spaces (or @ least 1 space), can use condition.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -