cucullen111
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Developing with WordPress
In reply to: Submitting Form Without All inputsHi Guys thankyou for fast responses…
I believe Its just the single page that is responsible for the form.jQuery(document).ready(function() { jQuery('.input-group.date').datepicker({ format: "yyyy/mm/dd", endDate: "2017/02/23" }); Dropzone.options.createProject = { addRemoveLinks: true, autoProcessQueue: false, parallelUploads: 10, maxFiles: 10, previewsContainer: ".dropzone-previews", dictDefaultMessage: '', clickable: '.upload-box', uploadMultiple:true, paramName:"picture", init: function() { var myDropzone=this; //these functions run when submit is clicked jQuery("#patient_submit").on('click',function(e) { console.log(validFrom()); if(validFrom()){ e.preventDefault(); e.stopPropagation(); var count= myDropzone.files.length; var empty_vals = 1; if(count > 0) { jQuery("#patient_submit").attr('disabled',true); myDropzone.processQueue(); } else { jQuery("#patient_submit").attr('disabled',true); myDropzone.uploadFiles([{name:'nofiles'}]); //send empty } } else{ console.log(error); return false } }); this.on('addedfile', function(file){ //jQuery('.upload-box').hide(); }); this.on('success', function(file){ var data = file.xhr.response; var response = JSON.parse(data); //console.log(response); if(response['status'] == 1){ jQuery('.error').html(''); jQuery('.error').hide(); jQuery(".callback-msg").removeClass('callback-error'); jQuery(".callback-msg").addClass('callback-success'); jQuery(".callback-msg").html(response['msg']); jQuery(".callback-msg").show(); jQuery("#createProject")[0].reset(); jQuery("#patient_submit").attr('disabled',false); setTimeout(function(){ location.reload(); },3000); } else if(response['status'] == 2){ jQuery('.error').html(''); jQuery('.error').hide(); for(var x in response['error']){ jQuery('.'+x).html(response['error'][x]); jQuery('.'+x).show(); } jQuery("#patient_submit").attr('disabled',false); } else if(response['status'] == 3){ jQuery('.error').html(''); jQuery('.error').hide(); jQuery(".callback-msg").addClass('callback-error'); jQuery(".callback-msg").removeClass('callback-success'); jQuery(".callback-msg").html(response['msg']); jQuery(".callback-msg").show(); jQuery("#patient_submit").attr('disabled',false); } }); } } jQuery(".teeth").on('click',function(){ jQuery(this).find('input[type=checkbox]').prop("checked", !$(this).find('input[type=checkbox]').prop("checked")); if(jQuery(this).hasClass("teeth_activ")) jQuery(this).removeClass("teeth_activ"); else jQuery(this).addClass("teeth_activ"); }); jQuery('.error').hide(); function validFrom(){ var error = true; jQuery('.error').html(''); jQuery('.error').hide(); jQuery('#createProject input[type="text"],#createProject select,#createProject textarea').each(function(index, element) { console.log(jQuery(this).val(),element); var attr = jQuery(this).attr("name"); if(jQuery(this).val().trim() == ""){ jQuery('.'+attr+'_error').html("This field is required"); jQuery('.'+attr+'_error').show(); error = false; } if(attr == "patient_email" || attr == "dentist_email"){ error = validateEmail(jQuery(this).val().trim(),attr) == true?error:false; } }); var fields = $("input[name='additional_info[]']").serializeArray(); if (fields.length === 0) { jQuery('.additional_info_error').html("This field is required"); jQuery('.additional_info_error').show(); error = false; } var fields = $("input[name='teeth1[]']").serializeArray(); if (fields.length === 0) { jQuery('.teeth1_error').html("Teeth1 section is required"); jQuery('.teeth1_error').show(); error = false; } var fields = $("input[name='teeth2[]']").serializeArray(); if (fields.length === 0) { jQuery('.teeth2_error').html("Teeth2 section is required"); jQuery('.teeth2_error').show(); error = false; } var fields = $("input[name='teeth3[]']").serializeArray(); if (fields.length === 0) { jQuery('.teeth3_error').html("Teeth3 section is required"); jQuery('.teeth3_error').show(); error = false; } var fields = $("input[name='teeth4[]']").serializeArray(); if (fields.length === 0) { jQuery('.teeth4_error').html("Teeth4 section is required"); jQuery('.teeth4_error').show(); error = false; } error = (radioValid('post_space') == true)?error:false; error = (radioValid('contact_like') == true)?error:false; error = (radioValid('report_sent')== true)?error:false; console.log(error); return error; } function radioValid(rname){ console.log(rname); var error = true; if (jQuery("#"+rname+":checked").length == 0){ jQuery('.'+rname+'_error').html("This field is required"); jQuery('.'+rname+'_error').show(); error = false; } return error; } }); </script>- This reply was modified 8 years ago by bcworkz. Reason: code fixed
Viewing 1 replies (of 1 total)