Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- $('.mainscreenform form').submit(function(event){
- event.preventDefault();
- let form = $(this);
- form.find('.form__reject').fadeOut();
- form.find('.form__resolve').fadeOut();
- form.find('.error').removeClass('.error');
- var formError = false;
- form.find('input').each(function (){
- if($(this).val() == ''){
- $(this).addClass('error');
- $(this).select();
- formError = true;
- return false;
- }
- });
- if (!formError) {
- let brand = form.find('input[name="brand"]').val();
- let model = form.find('input[name="model"]').val();
- let yearofissue = form.find('input[name="yearofissue"]').val();
- let yourphone = form.find('input[name="yourphone"').val();
- let loader = form.find('.form__loader');
- let wrapper = form.find('.form__wrapper');
- let resolve = form.find('.form__resolve');
- let reject = form.find('.form__reject');
- let items = form.find('.form__items');
- let formData = new FormData();
- formData.append('brand', brand);
- formData.append('model', model);
- formData.append('yearofissue', yearofissue);
- formData.append('yourphone', yourphone);
- $.ajax({
- url: '/form.php',
- type: 'POST',
- dataType: 'json',
- cache: false,
- contentType: false,
- processData: false,
- data: formData,
- beforeSend: function () {
- form.height(form.height());
- loader.fadeIn();
- items.fadeOut();
- },
- error: function (er) {
- loader.fadeOut();
- items.fadeOut();
- reject.fadeIn();
- console.log(er);
- },
- success: function(){
- setTimeout(function (){
- loader.fadeOut();
- items.fadeOut();
- resolve.fadeIn();
- form.find('input').val('');
- },1500);
- },
- complete: function () {
- }
- });
- }
- // return false;
- });
- });
Add Comment
Please, Sign In to add comment