Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Form Plugin & jQuery DatePicker Not Working Together
    text
    copied!<p>I'm trying to use jQuery's Form Plugin. I'm using the JSON example <a href="http://jquery.malsup.com/form/#json" rel="nofollow">here</a>. </p> <p>For some reason the datepickers are not showing on the page, when I use the jQuery Form Plugin. In my jquery file I've got:</p> <pre><code>jQuery.noConflict(); jQuery(document).ready(function($) { $('#csf_map_form').ajaxForm(function() { dataType: 'json', success: process_json }); function process_json(data) { alert(data.csf_map_offense_group1); } $('#csf_map_start_date').datepicker({ dateFormat : 'mm/dd/yy', yearRange : '2011:2011', changeMonth: true, changeYear: true, defaultDate : new Date(2011, 8-1,1), minDate : new Date(2011, 1-1,1), maxDate : new Date(2011, 8-1, 25) }); $('#csf_map_end_date').datepicker({ dateFormat : 'mm/dd/yy', yearRange : '2011:2011', changeMonth: true, changeYear: true, defaultDate : new Date(2011, 8-1, 25), minDate : new Date(2011, 1-1,1), maxDate : new Date(2011, 8-1, 25) }); }); </code></pre> <p>In my php file, the form looks like:</p> <pre><code> //start form $output .= '&lt;form id="csf_map_form" action="path-to-file/csf_map_form_handler.php" method="post" &gt;'; //1st datepicker $output .= '&lt;div&gt;'; $output .= '&lt;label for="csf_map_start_date"&gt;Start Date:&lt;/label&gt;'; $output .= '&lt;div id="csf_map_start_date" style="font-size: 10px;"&gt;&lt;/div&gt;'; $output .= '&lt;/div&gt;'; //2nd datepicker $output .= '&lt;div&gt;'; $output .= '&lt;label for="csf_map_end_date"&gt;End Date:&lt;/label&gt;'; $output .= '&lt;div id="csf_map_end_date" style="font-size: 10px;"&gt;&lt;/div&gt;'; $output .= '&lt;/div&gt;'; //radio button group div $output .= '&lt;div style="float: left; width: 150px; margin: auto; padding-left: 20px; "&gt;'; $output .= '&lt;label for="csf_map_group1"&gt;Select Offense:&lt;/label&gt;&lt;br /&gt;'; $output .= '&lt;input type="radio" name="csf_map_group1" checked="checked" value="TINY"&gt;Tiny&lt;/input&gt;&lt;br /&gt;'; $output .= '&lt;input type="radio" name="csf_map_group1" value="MEDIUM"/&gt;Medium&lt;/input&gt;&lt;br /&gt;'; $output .= '&lt;input type="radio" name="csf_map_group1" value="LARGE"&gt;Large&lt;/input&gt;&lt;br /&gt;'; $output .= '&lt;/div&gt;'; //end radiobuttons $output .='&lt;input type="submit" value="Submit" /&gt;'; $output .= '&lt;/form&gt;'; </code></pre> <p>For some reason the ajaxForm is conflicting with the datepicker. If I comment out the function starting $('csf_map_form').ajaxForm and the process_json function, then the datepickers in the form work fine. If I don't comment them out then the datepickers don't appear. But, the alert fires when submit is clicked. It alerts what was selected in the radiobutton. </p> <p>Any ideas as to what is going on? How do I get them to play nice? What error am I making?</p> <p>Thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload