Rail3: UJS submit after client-side validation

AppleII717
2010-08-14T15:24:45Z

I am have some problems with UJS.  I have a (potentially) large form
that I was doing client side validation on (yes there is also some
server side validation) using an old prototype validation routine that
is not working with the current version.

I actually got validation to work by coping and modifying some of the
rail.js routine to observer submit. I also had some javascript toggles
that I got to work.

I then found a post on behaviors:

http://weblog.jamisbuck.org/2010/3/2/unobtrusive-yet-explicit

This method worked great for my toggles, but then I tried to create
one for the submit button. While it did the validation, It would
always submit.

I then changed the input type to button and the validation would work,
but I could not get the form to submit.

Debugging all seemed to work (names, classes, etc)


Behaviors.add("click", "validate", function(element) {
  var formElements = $$(".required", ".required-one");
  var valid = true;
  var thisform = element.form
  ... validations stuff

but when I got to the end
  if(valid){thisform.submit()}

would fail saying the input element does not have a function submit.
thisform is reported as and htmlformelement.

I know this may be a little off target but I bet I am not the only one
using client-side validation.

If someone can point me in the right direction, I''ll go learn some
more.

Steve


--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at