Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » datepicker and onselect

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 506 Views
  • mgale
    Community Member
    1 Post

    datepicker and onselect Link to this post


    I am using Silverstripe 2.4.3 and jquery for form validation, following the example here:

    I have all the JS files specified in my Page.ss and have added the following to my page:
    function init() {
    jQuery(document).ready(function() {
    rules: {
    Paper: "required",
    NumberOfCopies: "required",
                   DateRequiredProduction: {
                      required : true,
                      date : true
    messages: {
    Paper: "Please pick a paper type",
    NumberOfCopies: "My default is a million copies",
                   DateRequiredProduction: "Let me know the date so I can exceed your expectations"


    Now form validation is working great so far with the exception of a DateField, if you enter a valid entry to start off then everything just works. If you do not enter a value in the field and trigger a validation error on submit. You need to select a date twice in order for the field to get validated.

    I believe is can be fixed by defining a callback in the onselect method and have it call my validate method?

    However I have tried several things to get that to work and so far none have been successful. I tried adding the following to the JS above:
    jQuery("#DateRequiredProduction").datepicker("option", "onSelect", function() {
                alert("this is test");

    But I just get:
    jQuery("#DateRequiredProduction").datepicker is not a function

    Any ideas?


Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.