Woocommerce Ajax Validate Checkout Form - woocommerce

I have one step checkout form and need to validate it in realtime without refreshing page, because I have custom payment method that need javascript to trigger the payment process. My problem now is that I could not find any functions or javascript library to validate my form.
What I want is want to get function that return true if the form is valid and return error message when the customer missing or input wrong information.
Please help!!!

Related

WPForms - Get Recaptcha value to perform manual control

I'm using the 'wpforms_frontend_form_action' filter to change the action attribute of my WPforms form.
I also use Google recaptcha v3 on that form, but its effect is limited and i still receive spam because bots get the modified action attribute which contains my final url directly in the script to bypass control.
What i'd need is to get the recaptcha value of my WPform and then perform the control myself before sending data to my final url.
How to get the WPforms recaptcha value ? The 'wpforms[recaptcha]' field is empty...
EDIT : I guess the recaptcha challenge is not launched until the user submits the form, so maybe there is an other way to change the action url of my WPForm AFTER the submission and not through the 'wpforms_frontend_form_action' filter ?
Thanks for help

How to disable AJAX sending method in Contact Form 7 and keep other JS options like validation

I would like to use wpcf7_form_action_url filter and change action in form.
To be able to do this, I need to disable the AJAX which is used when submitting the form
define('WPCF7_LOAD_JS', false) is not a solution because WPCF7 AJAX is packaged into an entire JS flag - so this will also turn off JS validation
if WPCF7_LOAD_JS JS is disabled, it will take the input to the server, validate and return to the form and show the errors. So, I think you not losing any validation functionality when submitting the form.

Realtime validation in database with custom field validator

I am creating a registration form in asp.net and I am trying to figure out how to check if the requested username is available upon lostfocus of the text field.
I setup a custom validation field but I can't seem to make it work on lostfocus.
Is there a way to do it?
What should I read?
Thanks
well you can check the username exist or not in custom validator. just check the url below. IT checks the user is exist or not.
Attach a custom validator to your textbox that hooks up to a validation method server side.
Using javascript, you'll need to hook up an eventhandler to the focusout event and make an ajax call. That call will send the value back to the server and get a response of valid or not.
http://brian.dobberteen.com/code/jquery_ajax_custom_validator/

Submit form to both code behind and third party url?

I have a legacy app that I need to change to accommodate a new payment processor.
The app is Asp.Net.
Without reconstructing the app (not in the budget) I need to take the final form and save information from it in the code behind, like it currently does, then I need to submit that same form to a third party url. Ideally as one button push to the end user.
I'm drawing a complete blank on a way to do this. Any suggestions?
Forgot to mention that JQuery and javascript are both valid tools for a solution.
You could create a javascript function that's bound to the form submit button's click event, or the form's submit event. The function will need to prevent the default form submission from firing. Use jQuery to serialize the form data, and create a synchronous AJAX request to submit the data to the third party. After the ajax submission has completed, you can trigger the form submission to the code-behind. If the ajax fails to submit properly, you can optionally abort the form submission to the code-behind.
You may need to account for XSS security, so look into cross-origin resource sharing and the Access-Control-Allow-Origin header.
Another option would be to have the code-behind behave as an http client and submit the form data to the third party.
so currently it's saving the results via code? Well, you could hack it by putting some javascript on the page that read's the forms values and posts them (eg with jquery), before doing you actual asp post.
edit (something like this might help (in some cases):
//change the action of the form (you could just change in code or this
$('#myform').attr('action','http://newpaymentproc.com/me/');
//override the default submit
$('#myformsubmitbutton').click(function(){
//extract the form data somehow (depends on form)
var formObj;
$.each($('#myform').find('input').serializeArray(), function(i, field) {
formObj[field.name] = field.value;
});
//post to old place
$.post('/old_current.asp', formObj).then(
//after posting to old place and getting response...
//submit form to new payment processor
$('#myform').submit()
);
// Cancel the actual form submit click to give time for post
return false;
});
Another way would be to have the legacy code (after submission) spit out a form with the data in it and some javascript to trigger submit on page load.
After the original process has completed, just take the submitted form data and push it to whichever URL you're working with. It requires minimal modification on the original app.
I have no code to go on, so I have no code to give. Hope that helps!

Open a new Gravity Form upon form validation error

I am looking for the best/easiest way to open/start a new gravity form when the current form fails validation. Example: user enters a zip code that is not valid upon submission. When the form fails validation a second form opens which is used to gather user contact info so they can be notified when their zip code is available.
Does anyone have an answer already to this that I was unable to find in the search or have any ideas as to a solution?
Thanks in advance.
You would have to tap into the action "gform_after_submission" and do a redirect to another page with that form. http://www.gravityhelp.com/documentation/page/Gform_after_submission
Another option would be to provide a drop down list of all the available zip codes with an additional option, like "mine is not in list". Then have some other fields that have conditional logic to only show if the "mine is not in list" value is selected.
http://www.gravityhelp.com/documentation/page/Form_Settings ( look for the conditional logic section)
Hope that helps.

Resources