Hi Friends,
I am a newbie on ROR, I made a authentication page for login. Now For
Validation at client side I want Javascript to be used.
Does Rails support client side vaildation as for server side methods are
already available?
Regards
HUNT
Hi Friends,
I am a newbie on ROR, I made a authentication page for login. Now For
Validation at client side I want Javascript to be used.
Does Rails support client side vaildation as for server side methods are
already available?
Regards
HUNT
Rails obviously support client side validation. all you need is to put
onsubmit event on whatever the form syntax you are using. below is an
example:
<% form_tag ({:action => “new”}, {:onsubmit => “return validate();”}) %>
then your basic javascript goes like:
function validate(){
if(document.getElementById(‘some_id’)==“”)
alert(“specify first name”);
}
On Wed, Sep 9, 2009 at 11:46 AM, HUNT HUNT
<[email protected]
wrote:
Regards
HUNTPosted via http://www.ruby-forum.com/.
–
Thanks and Regards
Puneet Pandey
Ruby on Rails Developer
In Puneet’s Lab: http://www.puneetpandey.com
Puneet Pandey wrote:
Rails obviously support client side validation. all you need is to put
onsubmit event on whatever the form syntax you are using. below is an
example:<% form_tag ({:action => “new”}, {:onsubmit => “return validate();”}) %>
then your basic javascript goes like:
function validate(){
if(document.getElementById(‘some_id’)==“”)
alert(“specify first name”);
}
Thanks Puneet,
On Wed, Sep 9, 2009 at 11:46 AM, HUNT HUNT
<[email protected]wrote:
Regards
HUNTPosted via http://www.ruby-forum.com/.
–
Thanks and Regards
Puneet Pandey
Ruby on Rails Developer
http://www.puneetitengineer.wordpress.com
In Puneet’s Lab: http://www.puneetpandey.com
I put the code but the result coming is that no action is performed on
click the button.
I haven’t found relevant information in google.
You can put it anywhere… in the index.html.erb or in layouts or in some
external javascript… in third case make sure that you are calling that
javascript like
On Wed, Sep 9, 2009 at 12:14 PM, HUNT HUNT
<[email protected]
wrote:
function validate(){
In Puneet’s Lab: http://www.puneetpandey.com
–
Posted via http://www.ruby-forum.com/.
–
Thanks and Regards
Puneet Pandey
Ruby on Rails Developer
In Puneet’s Lab: http://www.puneetpandey.com
I hope it will help
On Wed, Sep 9, 2009 at 2:31 PM, HUNT HUNT
[email protected]wrote:
I put the code but the result coming is that no action is performed on
click the button.I haven’t found relevant information in google.
Posted via http://www.ruby-forum.com/.
–
Thanks and Regards
Puneet Pandey
Ruby on Rails Developer
In Puneet’s Lab: http://www.puneetpandey.com
Ideally, javascript should be kept in head section of html, and for this
you
can use content_for tag. Read more about here:
अà¤à¤¿à¤¨à¤µ
http://twitter.com/abhinav
On Wed, Sep 9, 2009 at 2:31 PM, HUNT HUNT
Hey Puneet, The code which u send I tried with that…it is not
validating
instead it goes blank page saying undefined template.
THanks
Hunt
I am sure this time it will surely help you
On Wed, Sep 9, 2009 at 5:01 PM, HUNT HUNT
[email protected]wrote:
Posted via http://www.ruby-forum.com/.
–
Thanks and Regards
Puneet Pandey
Ruby on Rails Developer
In Puneet’s Lab: http://www.puneetpandey.com
Dude your javascript is not getting loaded when your submit button is
pressed… look carefully when you are calling javascript… try to alert
some
text to see what’s going wrong there
On Wed, Sep 9, 2009 at 5:29 PM, HUNT HUNT
[email protected]wrote:
can see the attached file…
Attachments:
http://www.ruby-forum.com/attachment/4020/Screenshot.png–
Posted via http://www.ruby-forum.com/.
–
Thanks and Regards
Puneet Pandey
Ruby on Rails Developer
In Puneet’s Lab: http://www.puneetpandey.com
Error says it all: you do not have “create” action in your controller.
Add it, it’s not a javascript issue anymore.
अà¤à¤¿à¤¨à¤µ
http://twitter.com/abhinav
On Wed, Sep 9, 2009 at 5:29 PM, HUNT
Tried again,
this time the output is a new page with
Unknown action
No action responded to create.
can see the attached file…
Abhinav S. wrote:
Error says it all: you do not have “create” action in your controller.
Add it, it’s not a javascript issue anymore.Thanks,
Abhinavअà¤à¤¿à¤¨à¤µ
http://twitter.com/abhinavOn Wed, Sep 9, 2009 at 5:29 PM, HUNT
I haven’t created any action in the controller…
Interestingly, the browser apparently can load the page quicker if
javascript is at the bottom.
James E. wrote:
Interestingly, the browser apparently can load the page quicker if
javascript is at the bottom.Best Practices for Speeding Up Your Web Site - Yahoo Developer Network
That’s a bizarre set of recommendations, especially given that Doug
Crockford, Yahoo!'s own JS architect, recommends that JS not be mixed in
with HTML at all.
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
On Wed, Sep 9, 2009 at 12:21 PM, Marnen
Laibow-Koser[email protected] wrote:
with HTML at all.
Other than one specific case of a certain kind of landing page, I
don’t see a recommendation there to mix javascript and html.
They recommend combining multiple script resources into one, minifying
etc.
I take putting the javascript at the bottom as putting the script tags
referencing the separate script resource(s) at the bottom not inlining
javascript in the page.
–
Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs