Codeigniter Jquery is not catching form

#1
[eluser]Nidheesh[/eluser]
Hello In my Blog Form i have inserted jquery but it is not catching the form validation .data insertion is functioning properly.here is my Code snapshots

View Code

Code:
<!DOCTYPE HTML>
&lt;head&gt;
&lt;meta http-equiv="content-type" c /&gt;
&lt;meta name="author" c /&gt;

&lt;title&gt;Title&lt;/title&gt;
    
    &lt;?=site_url() ?&gt;
&lt;/head&gt;
[removed][removed]

[removed]
$(document).ready(function(){
$('#Submit').click(function(){
  $('#addblog').Submit();
  return false;
})
})    
[removed]
[removed]
jQuery(document).ready(function() {

// validate signup form on keyup and submit
jQuery("#addblog").validate({
  rules: {
   blog_title: {
    required: true
   },
   blog_content: {
    required: true
   }
  },
  messages: {
  
   blog_title:{
    required: "Please enter the title"
   },
   blog_content : "Please enter Content"
  },
  submitHandler: function(form) {
    jQuery(form).ajaxSubmit({
     target: "#result1",
     resetForm: "true",
      success: function(data) {
      //jQuery('#saleUserId').val('');
      },
         debug:true
    });
   }
  
});
  });
[removed]

&lt;body&gt;
<h1>Add New Blog</h1>
<li><a href="&lt;?=site_url()?&gt;">Click Here</a></li>
<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p>
<fieldset><legend>Add New Blog</legend>
&lt;form acti method="post" name="SaveBlog" id="addblog"&gt;
<table width="58%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="47%" height="19" class="cont" align="center">&nbsp;</td>
        <td width="53%">&nbsp;<div id="result" ></div></td>
        </tr>
      <tr>
        <td height="19" align="left" class="cont">Enter Blog Title</td>
        <td align="left">&lt;input type="text" name="blog_title" id="blog_title" /&gt;&lt;/td>
    </tr>
    
     <tr>
        <td height="19" align="left" class="cont">Enter Blog Content</td>
        <td align="left">&lt;textarea name="blog_content" cols="50" rows="20" id="blog_content" &gt;&lt;/textarea></td>
        </tr>
      
    
          <tr>
        <td height="43" colspan="2" align="center">&lt;input type="submit" name="button" id="button" value="Submit"/&gt;&lt;/td>
        </tr>
      <tr>
        <td height="19" colspan="2" align="left">&nbsp;</td>
        </tr>
   </table>
   </fieldset>
   &lt;/form&gt;
  
   <h1>Data From Database through M and C</h1>

<h3>Current Blogs on the Screen</h3>


&lt;?
if(isset($Page_Data) && is_array($Page_Data))
{
foreach($Page_Data as $key => $val)
{
  $key = $val;
}
}
?&gt;
&lt;?
//print_r($Page_Data);
foreach($Page_Data as $row)
{
    ?&gt;
   <div>
   <span>
    <table>
    <tr>
    <td  blueviolet;">Title</td>
    <td  red;">&lt;?echo $row->title;?&gt;</td>
    
    </tr>
    
    
    <tr>
    <td  blueviolet;">Content</td>
    <td  red;">&lt;?echo $row->content;?&gt;</td>
    </tr>
    
    </table>
    
    </div>
    
    
    <div>
    
    </span>
    </div>
    
    
&lt;?}
?&gt;http://localhost:8088/samplesite/index.php/Blog/





&lt;/body&gt;
&lt;/html&gt;

Folder Structure is also attached..

#2
[eluser]jonez[/eluser]
Remove this:

$('#Submit').click(function(){
$('#addblog').Submit();
return false;
});

jQuery Validate adds its own handler to the form submit event. Once the above code is removed the validation rules should be triggered when you try to submit the form. The code above triggers the event manually and will skip the form validation rules.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.