Jquery form submit validation

0 votes

I have following form:

<form id="testForm" action="country_Save">
   Country Name:<input type="text" id="countryName" />  
   <input type="submit" id='saveCountry' value="Add Country" />
</form>

and following JQuery for validating textfield

$('#testForm')
   .jqxValidator({  rules : [
          {
              input : '#countryName',
              message : 'Country Name is required!',
              action : 'keyup, blur',
              rule : 'required'
          }],
          theme : theme
});

How can i use this validation when I am submitting a form?

Jun 20, 2022 in JQuery by gaurav
• 23,260 points
3,164 views

1 answer to this question.

0 votes

Bind a function to the submit event of the form. Return false in this function if any of the form fields fail validation.

For example:

$('form').on('submit', function() {
    // do validation here
    if(/* not valid */)
        return false;
});
answered Jun 20, 2022 by rajatha
• 7,640 points

Related Questions In JQuery

0 votes
1 answer

A simple jQuery form validation script

use jQuery validation plugin to validate forms' ...READ MORE

answered Jun 1, 2022 in JQuery by Edureka
• 13,670 points
1,190 views
0 votes
1 answer

Submit a form using jQuery

This method is a shortcut for .on( ...READ MORE

answered Jun 6, 2022 in JQuery by Edureka
• 13,670 points
480 views
0 votes
1 answer

How to convert form data to JavaScript object with jQuery?

Hello @kartik, You can use: function form_to_json (selector) { ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,880 points
2,684 views
0 votes
1 answer

How to make a simple modal pop up form using jquery and html?

Create A Modal <button onclick="document.getElementById('id01').style.display='block'" class="w3-button">Open Modal</button> ... <div ...READ MORE

answered Jun 2, 2022 in JQuery by Edureka
• 13,670 points
6,865 views
0 votes
0 answers

Email validation using jQuery

How can I use JQuery to validate ...READ MORE

May 21, 2022 in JQuery by Kichu
• 19,050 points
241 views
0 votes
1 answer

Email validation using jQuery

You can use regular old javascript for ...READ MORE

answered Jun 3, 2022 in JQuery by Edureka
• 13,670 points
398 views
0 votes
1 answer
0 votes
0 answers

jQuery validation of NANP Phone numbers

I'm trying to validate my form. In ...READ MORE

Aug 19, 2022 in Web Development by gaurav
• 23,260 points
986 views
0 votes
1 answer

Jquery validation plugin - TypeError: $(...).validate is not a function

The "$(...). validate is not a function" ...READ MORE

answered Jun 28, 2022 in JQuery by rajatha
• 7,640 points
14,433 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP