وردپرس

Validate before sending to CRM


Replies: 0

I’m using the recommended method to submit my form data to an unsupported CRM

var wpcf7Elm = document.querySelector( '.wpcf7' );
		
		wpcf7Elm.addEventListener( 'wpcf7submit', function( event ) {
//Code to send to CRM

But I am having a problem where users are able to click the submit button without filling all the fields and blank entries are going to the CRM.

I’ve been trying to set up my form to have the submit button disabled until all required fields have values. But that isn’t working. I am finding the form isn’t enabling the submit button after all fields have been filled.

I’ve been trying to use this with no success

jQuery(document).ready(function() {
				jQuery('.wpcf7-submit').prop('disabled',true);
			});
			
			(function() {
				jQuery('form > input').keyup(function() {
					
					var empty = false;
					jQuery('form > input').each(function() {
						if ($(this).val() == '') {
							empty = true;
						}
					});
					
					if (empty) {
						jQuery('.wpcf7-submit').prop('disabled',true);
					} else {
						jQuery('.wpcf7-submit').prop('disabled',false);
					}
				});
			})()		

Any guidance as to where I’m going wrong would help me out a lot.

پایان/ مرجع وب و فناوری

مشاهده پاسخ های این مطلب
———————————————
این مطلب از سایت انجمن وردپرس گردآوری شده است و کلیه حقوق مطلق به انجمن وردپرس می باشد در صورت مغایرت و یا بروز مشکل اطلاع دهید تا حذف گردد

منبع: انجمن وردپرس

دکمه بازگشت به بالا