Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

765 Posts in 246 Topics by 252 members

Form Questions

SilverStripe Forums » Form Questions » Custom validation

Page: 1
Go to End
Author Topic: Custom validation 1123 Views
  • Dipak
    avatar
    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
    avatar
    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.

    Example:

    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
    avatar
    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,

    Terry

  • Elemental
    avatar
    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.

    thanks
    angelo

    1123 Views
Page: 1
Go to Top

Currently Online: paul.mcilwaine, motly, jondbaker

Welcome to our latest member: fearofbuttons

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

Comments on this website? Please give feedback.