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

I was wondering how I would write a regex expression which says 'and NO whitespaces'.I need to implement this into the following if statement, see below:

    var postcode = $(this), val = postcode.val();

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

Any help is greatly appreciated, Thanks


Try this:

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

match return null if there are no spaces (or at least one space), so you can use it as a condition.

Need Your Help

calculating vertex normal in opengl c++ ( gouraud shading)

c++ opengl vector

I just started learning C++ and OpenGL. I'm trying to calculate vertex normal in OpenGL.

Post-image move before post-header on each single-post through jquery

javascript jquery html

I want if some body add div with class "post-image". It will automatically move it before div with class "post-header" and do this function on each div with class single-post.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.