doug livesey
2006-Mar-24 12:14 UTC
[Rails] JS validation on a form/submit tag? Like :condition=>...
Hallo -- is there a way anyone know of that I can add a :confirm clause to a form submit? Something like: <%= submit_tag ''commit'', :confirm=>"are you certain?" %> Does anyone know how to achieve this? Cheers, doug. -- Posted via http://www.ruby-forum.com/.
Jonathan Viney
2006-Mar-24 12:18 UTC
[Rails] JS validation on a form/submit tag? Like :condition=>...
My guess is that would need to go in the onclick handler for the form. <form .... onclick="return confirm(''Are you sure?'')"> -Jonny. On 3/25/06, doug livesey <biot023@gmail.com> wrote:> > Hallo -- is there a way anyone know of that I can add a :confirm clause > to a form submit? Something like: > <%= submit_tag ''commit'', :confirm=>"are you certain?" %> > Does anyone know how to achieve this? > Cheers, > doug. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/20a0c07d/attachment.html
Peter Ertl
2006-Mar-24 12:54 UTC
[Rails] JS validation on a form/submit tag? Like :condition=>...
>From the top of my head I remember this.However, check it in different browsers first! <form onsubmit="return confirm(''REaLlY?''">> --- Urspr?ngliche Nachricht --- > Von: "Jonathan Viney" <jonathan.viney@gmail.com> > An: rails@lists.rubyonrails.org > Betreff: Re: [Rails] JS validation on a form/submit tag? Like > :condition=>... > Datum: Sat, 25 Mar 2006 00:18:36 +1200 > > My guess is that would need to go in the onclick handler for the form. > > <form .... onclick="return confirm(''Are you sure?'')"> > > -Jonny. > > On 3/25/06, doug livesey <biot023@gmail.com> wrote: > > > > Hallo -- is there a way anyone know of that I can add a :confirm clause > > to a form submit? Something like: > > <%= submit_tag ''commit'', :confirm=>"are you certain?" %> > > Does anyone know how to achieve this? > > Cheers, > > doug. > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
doug livesey
2006-Mar-24 14:31 UTC
[Rails] Re: JS validation on a form/submit tag? Like :condition=>...
Hi -- the way I did it was like this: I created a helper method in ''application_helper.rb'': def confirm_submit_tag(value="submit", msg="Are you sure?") "<input type=\"submit\" value=\"#{value}\" onclick=\"return confirm(''#{msg}'');\" />" end & then, in the rhtml (inside the form), I can just use <%= confirm_submit_tag ''commit'', "This will commit the changes you made." %> It works well in firefox & IE. Cheers for the input! doug. -- Posted via http://www.ruby-forum.com/.