save form data jquery 1

save form data jquery

    $("#mybtn").click(function(e) {
        if (conatcForm.valid() === true){
            var formData = JSON.stringify($("#contact-form").serializeArray());


Here is what the above code is Doing:
1. We are using the jQuery library to select the button with the id of mybtn.
2. We are using the click() method to attach a click event handler to the button.
3. We are using the valid() method to check if the form is valid.
4. If the form is valid, we are using the serializeArray() method to serialize the form data into an array.
5. We are using the JSON.stringify() method to convert the array into a JSON string.
6. We are using the console.log() method to log the JSON string to the console.

Similar Posts