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
Post a Comment