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.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Option to leave out javascript validation

Go to End

7 Posts   3000 Views


Community Member, 501 Posts

10 October 2007 at 12:53am

Currently there doesn't seem to be a way to leave out javascript validation without hacking into the validator.php file, not a problem for me but not so good for upgrading.

Doing on Requirements::clear(..) doesn't help, as the js will always be included when using 'new requiredfield'.


Forum Moderator, 801 Posts

10 October 2007 at 5:53am

the trick is to clear requirements as close to rendering as possible:
in your case of form-validation, this would be YourCustomFormClass->forTemplate()

but you're right, there should be a switch to disable client-side validation...


Community Member, 156 Posts

28 April 2008 at 12:41pm

dio5, did you sort this out and get Requirements::clear() to work correctly?


Administrator, 690 Posts

15 May 2008 at 3:39pm

Edited: 15/05/2008 3:39pm

Perhaps we should add a couple of useXXValidation() methods on the form, to turn this on / off?


If we did that, the best thing would be to have a FormField::includeJavascriptValidation() method that was called on each Field as part of the form rendering, if javascript validation was selected. It would be a bit of a refactoring, but it would put the responsibility for deciding whether to include javascript validation in the hands of the Form object, which is more appropriate than in the individual form fields.

If we can make a patch for this on trunk, then Dio5 / Blackdog can apply it to their own branches before the next release.


Community Member, 156 Posts

22 May 2008 at 10:14am

Dio5, I never could get the clear() to work even if I targeted the individual files.


Community Member, 501 Posts

23 May 2008 at 7:27am

Sam, that sounds like a good idea.

I managed to work around this with subclassing RequiredFields and returning empty javascriptvalidation functions. - i e overriding those functions in Validator that make the js validation with a blank method.


Community Member, 712 Posts

23 May 2008 at 3:43pm

W/regards Sam's comment, I'd be particularly interested in the ability to override any SS generated javascript with my own.

For example, I use jQuery, so it totally sucks to have prototype imported and used to validate forms when there is an excellent jQuery Validitor plugin that is very easy to template and would add very little overhead to my existing pages. If the hooks were available, devs could produce jQuery/Mootools/YUI ports to perform these common tasks.

If someone is already doing this, or there is a workable solution already, please let me know. Otherwise I'm interesting in helping produce such a framework if someone wants to point me in the right direction.