javascript - Date picker JS: how to have it work on multiple form fields -


i using plugin wp: http://wordpress.org/plugins/cf7-datepicker-alternative/

the .js file includes code:

jquery(document).ready(function($) {   $('#fieldname1').datepicker({      autoclose: true   }); }); 

does know how doctor bit of code date picker function in multiple fields in same form, such fieldname2 , fieldname3 fieldname1?

i thank in advance efforts.

instead of using id attribute, assign meaningful class e.g. datepicker elements want datepicker on. update javascript use class selector.

example:

<!-- html --> <input type="text" id="fieldname1" class="datepicker" /> <input type="text" id="fieldname2" class="datepicker" />  // jquery jquery(document).ready(function($) {   $('.datepicker').datepicker({      autoclose: true   }); }); 

update:

if don't want use class selectors , want use multiple ids, following:

<!-- html --> <input type="text" id="fieldname1" /> <input type="text" id="fieldname2" />  // jquery jquery(document).ready(function($) {   $("#fieldname1, #fieldname2").each(function() {      $(this).datepicker({        autoclose: true      });   }); }); 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -