Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Contact Form and Signup Form validation clashing


Reply


8 Posts   1574 Views

Avatar
Briohny

Community Member, 199 Posts

27 March 2009 at 4:45am

I have a contact (userdefined form) and a newsletter signup ($SignUpForm) on the same page. The validation is messy. When you hit submit on the contact form, an error message appears 'object does not support this property or method' and the form validation fields turn from strings to 'EditableEmailField3 is required'.

Does anyone know how i can fix this please?

Many thanks.

Avatar
Carbon Crayon

Community Member, 598 Posts

8 April 2009 at 2:18am

Edited: 08/04/2009 2:19am

Hi Briohny

I had this issue to and didn't find a way to have the SS validator working on two form siultaniously so I just disabled it from one of them changing the id of the <form> element from 'Form_Form' to 'QuestionForm' using a line of jQuery: $('#questionForm form').attr('id', 'QuestionForm');

I then wrote a simple jQuery validator to replace it on that form.

Hope that helps

Aram

Avatar
TerryMiddleton

Community Member, 108 Posts

19 May 2009 at 4:36am

Aram & Briohny,

So, this may be a sort of different question than the two forms issue, however I'm trying to ADD a form field validation and I can't seem to figure it out.

On my customform, can I simply add a validator just for the field I'm trying to validate. It looks like for required fields the validator is already add.

Then, what in the world does this look like?

Thanks for your insight,

Terry

Avatar
Carbon Crayon

Community Member, 598 Posts

19 May 2009 at 5:07am

Edited: 19/05/2009 5:10am

Hi Terry

if you look at my [url=http://ssbits.com/creating-a-simple-contact-form/]tutorial for creating a simple contact form[/url] in part 2 you will see a bit where we define $validator[ with the names of the fields we want to be validated. Then you just pass this into the Form() function as an argument and that's it, validation added :)

EDIT: actually I think I misunderstood your question......not entirely sure what you mean, you don't want to add a required field but you do want it to be validated? I'm confused :s

Avatar
TerryMiddleton

Community Member, 108 Posts

19 May 2009 at 5:35am

Aram,

My apologies for the confusion.

I actually do have a required field that I also need to add some more validation to. Specifically, I have a phone number field that is required and I also need to make sure the field has at least 10 digits to it.

Everything works perfectly, except now I need to add the extra validation for the 10 digits on the phone #.

I'll check out the tutorial. Thank you for responding. I'm (I pray) down to the last 10 items that the client is asking for and I can go live. (first SS project)

Thanks again,

Terry

Avatar
Carbon Crayon

Community Member, 598 Posts

19 May 2009 at 5:42am

Edited: 19/05/2009 5:43am

Ahh ok I am with you now. There is a [url=http://doc.silverstripe.com/doku.php?id=phonenumberfield]phone number field[/url] although it's for newzeland numbers so not sure it it will do what you want.

Otherwise if I were you I would remove the SS validation from the field and then add some custom jquery validation to the field using a seperate script.

And ignore my reference to that tutorial, it wont help :)

Avatar
Carbon Crayon

Community Member, 598 Posts

19 May 2009 at 5:47am

There is an example of some simple jQuery validation here: http://www.willjessup.com/sandbox/jquery/form_validator/form_validate.html

Avatar
TerryMiddleton

Community Member, 108 Posts

19 May 2009 at 5:53am

Aram,

yeah, yeah - I was headed that way with the jquery validation, then my brain got tweated on how to implement it.

I'll head back to the jquery solution.

Thanks,

Terry