Divyesh Patoriya Divyesh Patoriya - 1 year ago 88
PHP Question

How to stop execution if validation is fire using jquery

Problem is there validation fire but submit form after submit button press.

Mean validation work properly, but after that form will submit which is wrong.

Here is my Code:

<script type="text/javascript">
var evename=$("#Editname").val();
type: 'POST',
url: 'middle/edited_save_event_data.php',
dataType: "json",
data: {name:evename},
success: function(data) {
$("#lightboxscheduleedit, #lightbox-panelscheduleedit").fadeOut(300);




And This is Html:

<div id="lightbox-panelschedule">
<a id="close-panel" href="#"><img src="images/close-light.png"></a>
<h4 class="light_box_title">Add New Event</h4>
<div id="light_table">
<form name="addevent" id="add" method="post" action="add-trainer-event">
<div id="leftfirst">
<div class="main_login_form trainer_form">
<div class="post_form_row">
<label>Event Name:</label>
<input type="text" name="ename" class="required" id="ename">


<div class="clr"></div>

Answer Source

Try with the following code ..

    $("#add").on('submit', function(e){
        var isvalidate=$("#add").validate();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download