Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Custom validation

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

Page: 1
Go to End
Author Topic: 2855 Views
  • Dipak
    Community Member
    8 Posts

    Custom validation Link to this post

    Hello friends,
    I am using silverstripe 2.3.0 rc1

    I want to use custom validation on the phone field, please guide me in the same, I want to use javascript for validation

    here is code snippet

    function Form() {
          return new Form($this, "Form", new FieldSet(

             // List your fields here
             new TextField("ContactPerson", "Contact Person"),
             new EmailField("Email", "Email address"),
             new DropdownField("Reason", "Your Reason", array(
    "Sales" => "Sales",
    "Marketing" => "Marketing")),
             new PhoneNumberField( $name = "PhoneNumber",
                            $title = "Phone Number "
             new TextareaField( $name = "Remarks",
                            $title = "Remark",
                            $rows = 8,
                            $cols = 3)

          ), new FieldSet(

             // List the action buttons here
             new FormAction("SubmitAction", "Submit"),
             new ResetFormAction("ClearAction","Clear")

          ), //new CustomValidator($javascriptCode)
             //new CustomValidator("<script>window.open('new.html')</script>")
             //new ContactFormValidation()
             new RequiredFields("ContactPerson","Email","Reason","PhoneNumber"   )

    reply become appreciable.
    please hurry..
    Thank You

  • Nexus Rex
    Community Member
    8 Posts

    Re: Custom validation Link to this post

    I need help as well figuring out how to disable/enable some fields according to the state of a radio button.


    Are you over 18? () Yes () No
    If No:
    Parent's Email: __________________________

    Why does it seem that 70% or more of good questions on this forum go unanswered? I think this forum's lack of quick user help is going to hurt SS.

  • TerryMiddleton
    Community Member
    108 Posts

    Re: Custom validation Link to this post

    Hi Dipak,

    Hey did you ever get the customvalidation to work with the javascript?

    I have the exact same situation, but can't figure it out to save my life.

    What did you end up doing?

    I simply want to add to the required field validation and add a validator for a phonefield to be at least 10 digits in length.

    Let me know if you solved this,


  • Elemental
    Community Member
    8 Posts

    Re: Custom validation Link to this post

    Hi Terry, Dipak,

    Did you guys find a solution for that validation and your problems?

    Please let me know.


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.