Re: [newbie] Intercepting client-side form validation/submission
Use Event.observe for the form and use the validation with custom JS of urs... HTH - Ashwanth Kumar On Wed, Dec 23, 2009 at 3:48 PM, Kenneth CH, LEE wrote: > There is a submit button within the form. I could not attach the code > in onclick handler because I want it to run only if the form is valid. > > 2009/12/22 Ashwanth Kumar : > > On Tue, Dec 22, 2009 at 6:14 PM, Kenneth CH, LEE > wrote: > > > >> Hi there, > >> > > > > Hello, > > > > > >> > >> Is there any existing facilities to trigger some custom Javascript > >> code _after_ validating the form? > >> > >> I'm now doing it with some Javascript tricks: > >> === > >> > >> ... > >> > >> Event.observe(window, "load", function() { > >>var f = $("myform").onsubmit; > >>$("myform").onsubmit = function(e) { > >>return f(e) && customFunction(); > >>}; > >> }); > >> > >> > >> ... > >> > >> function customFunction() { > >> //return true to submit > >> } > >> > >> === > >> > > > > When exactly do u submit ur form?? > > > > > >> Notice that the custom function is only called _after_ validation > >> _and_ only if it was successful. > >> > > > > Well, if you want to do a custom JS, u can do a Zone Update of the Form, > > then observe Tapestry.ZONE_UPDATED_EVENT, for doing some some custom JS! > > But, that happens only after form submission and not before that! > > > > HTH > > - Ashwanth Kumar > > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >
Re: [newbie] Intercepting client-side form validation/submission
There is a submit button within the form. I could not attach the code in onclick handler because I want it to run only if the form is valid. 2009/12/22 Ashwanth Kumar : > On Tue, Dec 22, 2009 at 6:14 PM, Kenneth CH, LEE wrote: > >> Hi there, >> > > Hello, > > >> >> Is there any existing facilities to trigger some custom Javascript >> code _after_ validating the form? >> >> I'm now doing it with some Javascript tricks: >> === >> >> ... >> >> Event.observe(window, "load", function() { >> var f = $("myform").onsubmit; >> $("myform").onsubmit = function(e) { >> return f(e) && customFunction(); >> }; >> }); >> >> >> ... >> >> function customFunction() { >> //return true to submit >> } >> >> === >> > > When exactly do u submit ur form?? > > >> Notice that the custom function is only called _after_ validation >> _and_ only if it was successful. >> > > Well, if you want to do a custom JS, u can do a Zone Update of the Form, > then observe Tapestry.ZONE_UPDATED_EVENT, for doing some some custom JS! > But, that happens only after form submission and not before that! > > HTH > - Ashwanth Kumar > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: [newbie] Intercepting client-side form validation/submission
On Tue, Dec 22, 2009 at 6:14 PM, Kenneth CH, LEE wrote: > Hi there, > Hello, > > Is there any existing facilities to trigger some custom Javascript > code _after_ validating the form? > > I'm now doing it with some Javascript tricks: > === > > ... > > Event.observe(window, "load", function() { >var f = $("myform").onsubmit; >$("myform").onsubmit = function(e) { >return f(e) && customFunction(); >}; > }); > > > ... > > function customFunction() { > //return true to submit > } > > === > When exactly do u submit ur form?? > Notice that the custom function is only called _after_ validation > _and_ only if it was successful. > Well, if you want to do a custom JS, u can do a Zone Update of the Form, then observe Tapestry.ZONE_UPDATED_EVENT, for doing some some custom JS! But, that happens only after form submission and not before that! HTH - Ashwanth Kumar
[newbie] Intercepting client-side form validation/submission
Hi there, Is there any existing facilities to trigger some custom Javascript code _after_ validating the form? I'm now doing it with some Javascript tricks: === ... Event.observe(window, "load", function() { var f = $("myform").onsubmit; $("myform").onsubmit = function(e) { return f(e) && customFunction(); }; }); ... function customFunction() { //return true to submit } === Notice that the custom function is only called _after_ validation _and_ only if it was successful. Since this is all boiler-plate I'm going to make it a component that can be nested within , but before that I want to make sure I'm not reinventing something that already exist. Or just tell me if I'm going the wrong way and the _proper_ way to do it. Your input is much appreciated. Kenneth - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org