I have a jsfiddle here - <http://jsfiddle.net/1Lo7ag21/6/>

I have a name input where I would like the first and second name 

I'm trying to validate a name field by checking for a space.

How can I check that the field contains a space and display the alert if it doesn't

```
    $('button').click(function(e){

        e.preventDefault();

        var name = $('#name').val();

        if(name.length == 0 && name.indexOf(' ') === -1){
            alert('Add first and last name with a space');
        }

    })

```