Basic form check example with jQuery and javascript push method

<script type="text/javascript">
$(document).ready(function() {

$('#myForm').submit(function(){
    var errors = new Array();
    if($('input[name=first_name]').val()=='') {
        errors.push('Enter your first name');
    }
    if($('input[name=last_name]').val()=='') {
        errors.push('Enter your last name');
    }

    if(errors.length>0) {
        var message = errors.join('<br />');

// show the message in a hidden div
        $('#modal #errors').html(message);

// show the div

       $('#modal').show();
       return false;
    }

});

});

</script>