text: jQuery(document).ready(function() {
  
    var form = $('#form'),
        name = $ ('#name')
        email = $('#email'),
        mobile = $('#mobile'),
        submit = $("#submit"),
        info = $('#info');
    
    form.on('input', '#email, #mobile, #name', function() {
      $(this).css('border-color', '');
      info.html('').slideDown();
    });
    
    submit.on('click', function(e) {
      e.preventDefault();
      if(validate()) {
        $.ajax({
          type: "POST",
          url: "mailer.php",
          data: form.serialize(),
          dataType: "json"
        }).done(function(data) {
          if(data.success) {
            email.val('');
            name.val('');
            mobile.val('');
            info.html('Message sent!').css('color', 'green').slideDown();
          } else {
            info.html('Could not send mail! Sorry!').css('color', 'red').slideDown();
          }
        });
      }
    });
    
    function validate() {
      var valid = true;
      var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
      
      if(!regex.test(email.val())) {
        email.css('border-color', 'red');
        valid = false;
      }
      if($.trim(name.val()) === "") {
        name.css('border-color', 'red');
        valid = false;
      }
      if($.trim(mobile.val()) === "") {
        mobile.css('border-color', 'red');
        valid = false;
      }
      
      return valid;
    }
  
  });