jquery event.preventdefault problem
<p>My <code>event.preventdefault</code> is not working. Actually I want when the user clicks the add button, it will ask to "enter the field first" if all the field are blank.</p>

<p>For this, I use the flag like this to prevent the data saved if all fields are blank as below: (also when i click the button it shows enter the field and after that it will go to ajax function even i applied <code>event.preventdefault();</code> I don't know exactly where I am wrong) </p>

<p>Thanks in advance,</p>

<p><strong>Here is my code:</strong></p>

<pre><code> &lt;tr&gt;
        &lt;td&gt;
            &lt;button type="button" name="add"&gt;     //this is my add button
                Add
            &lt;/button&gt;
        &lt;/td&gt;
   &lt;/tr&gt;
       $("#tabs").tabs();
       $("button").button();
       $("button").click(function(event){
            var flagg=0;
            if( $("#patient_name").val() == "" )
            {
                flagg=1;
            }
            if(flagg == 1)
            {
                alert("enter the patient name!!");
                event.preventDefault();
            }

        form_name = $(this).parents("form").attr('name');
        var params    = $("#" + form_name).serialize();
        params=params.replace(/&amp;/g,'~^~^^');
        table_name = "patient_info";
        button_name = "temp";

        $.ajax({
             type: "POST",
             url: "ajax1.php",
             data: "params=" + params + "&amp;button_name=" + button_name,
             success: function(msg){
                 //alert(msg);
                if (msg == "true")
                {
                    alert("Patient data sucessfully saved!");
                    window.location.replace("ivf2.php?id=" + $("#id").val());
                }   
                else    
                {
                    //alert("Failed to save, please check and try again!");
                }
        }
        });
  });
</code></pre>
