spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Ajax Validation intrupt the form submit on form submit event


You may need to create a separated function to submit your form as a callback of the validation ajax process and pass the serialized data to it, something like :

function submitForm(serializedData) {
    jQuery.ajax({
        ur: "{your form action processing file}",
        type: "POST",
        data: serializedData,
        success: function (data, textStatus, xhr)
{
            console.log("form submitted
"+xhr.status) // 201 if everything OK
            // optionally reload the page
            window.location.reload(true);
        }
    });
}

jQuery(document).ready(function ($) {
    // validate form
    $("#myForm").on("submit", function (event) {
        // prevent form from being submitted
        event.preventDefault();
        // collect your form data to be submitted 
:
        var serializedData =
$("#myForm").serializeArray();
        $.ajax({
            url : "validate.php",
            type: "POST",
            cache: false,
            dataType : "json",
            data : {email : 'example@domain.com'},
            success: function (response) {
                if(response.status == '1'){
                    // email is valid so submit
the form
                    submitForm(serializedData);
                } // you don't need an else
statement since we already used
event.preventDefault() before the ajax call
            },
            error: function () {
                console.log("ajax validation
error");
            }
        })
    }); // on submit    

}); // ready

Notice we assigned a selector (#myForm) to the form we are processing.


Categories : PHP

Related to : Ajax Validation intrupt the form submit on form submit event
Multiple clicks in Submit causes validation to close longer Jquery Validation Engine
In order to actually prevent the default action/event your first code needs to be like this $('#contactForm').on('submit', function (e) { e.preventDefault();//prevent the default action from occuring if (!$("#contactForm").validationEngine('validate')) { } else { $('[type="submit"]').prop('disabled', 'disabled'); } });

Categories : Javascript
Form with validation won't submit on Mobile
I'm seeing some loose closing tags. </h2> </div> <div class="liNav"> <input type="button" value="SUBMIT" id="fSubmit" onclick="vForm();" /> </form> You could replace these lines with this: <div class="liNav"> <input type="button" value="SUBMIT" id="fSubmit" onclick="vForm();" /> </div> </form> There's another big i

Categories : Jquery
ASP .Net MVC jQuery validation does not work on form submit but works onfocusout
if you want to check control in view is valid through DataAnnotation means [Required] for property as you write in model ,then use HTML.Helper "@Html.TextAreaFor(model => model.Property) @Html.ValidationMessageFor(model => model.Property)" this perform validation for you not use html tags like as you write "<textarea>...</textarea>"

Categories : Jquery
Track submit event in new window javascript
It is possible if the page opening the window and the page that is opened are from the same origin... var win = window.open('form.html', 'formwin'); win.addEventListener('submit', function () { console.log('parent: submit') }); Demo: Plunker If they are not, the the browser security policy won't allow you to access the contents of the new window. http://security.stackexchange.com/questio

Categories : Javascript
How to submit a form when load page and when submit form?
This should work for you: (It's submit's the form when the document is ready) $(document).ready(function(){ $("#form").submit(); }); To automatic submit your form use: <script language="javascript"> $(function(){ $("form").submit(); }); </script> (But be sure your action is not on the same page!) EDIT: So your script should look something like this: <

Categories : Javascript
Recently Add
Cartesian product of associative array showing key and value - PHP
Datamapper orm save and update not working
find methods in COM object
PHP Keyword search not working with multiple words
Set a total based on items ordered, two types, and sometimes one type will not be ordered.
FB request to join a group, going around their official SDK
Using Google charts with php data?
OAuth2 integration with ExactOnline
libvirt-php receives the error: unable to connect to server Permission denied
How to echo results by sets of 2?
Why does PHP's sprintf not round 5s reliably?
php replace affects on replaced string
PHP Find and replace multiple similar entries
Replace PHP date output with pre-made images
How to install Laravel 4 packages on Windows
Using updateOrCreate for multiple data insert in Laravel
Storing products in a MYSQL database and then search and filter them?
Create order with PrestaShop's API
how to get latest messages from all users
Yii CMultiFileUpload Restrict Image width
Combine array by key factor
Semicolon after if condition in PHP - code still works
Get date using day of the week
soap web service with symfony
Seasonal Reservation system Day/month
is it possible to join a single table it self?
Attempting to compare two arrays PHP
Sticky Select Option
Eventbrite duplicate event entry
Pagination Not Working on custom post type in Wordpress
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.