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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Validation on forms using JS

Go to End

13 Posts   3504 Views


Community Member, 7 Posts

8 July 2009 at 3:39pm

You can do a Requirements::block(...) to prevent a file from being loaded, then add your file - you'll have to copy whole file though.


Community Member, 8 Posts

8 July 2009 at 8:00pm

so should I block the JS file that is being called in sapphire/javascript/?

surely there is another way to change this error handling in javascript?


Community Member, 7 Posts

8 July 2009 at 9:16pm

Try blocking the script, then in setting up Requirements re-add script and then add your own script with a custom 'validationError' function which could change functionality. If you manually add them I believe it keeps the correct order, and they are 'global' functions so latest will override previous.

The current function appends a span with class "message required" to the parent element of the field with the "<field-name> is required" message. Instead change the function to change the field to, e.g. a red border (or the parent element).

You could do this with CSS selector on the span with "message required" :prev type selector (and set the span itself to display: none) but this probably doesn't work on many browsers.

You may need to block the default CSS and add your own/override styles where applicable too.


Community Member, 8 Posts

8 July 2009 at 9:27pm

Thanks guys, I got it solved.

I had to do the block and then include my file as you guys mentioned.

However my JS file had to have the same content as the sapphire file and then I could override the function.

here is the code that worked:





Community Member, 30 Posts

8 July 2009 at 9:31pm

What about the changes in the JS-File you did?

Go to Top