It’s been awhile since a post, but I was on vacation, and then there is the post vacation week of recovery. I don’t have anything big to post, but I figured I’d better post something otherwise I’ll just give up completely on this blog and I don’t want to do that.
So a brief little problem I’ve been working on today is how to do some pre-submit client side validation on a form element in rails if I’m using the remote_form_tag to create my tag. I found a great little solution that was sitting right in front of me the whole time, but it took this article for me to see it. Basically you just use the :before parameter to call your validation script and then just return false if it fails, how great is that. Just another rails solution that ends up being easy as long as you just look at the available tools the right way.
September 28, 2006 at 5:10 pm |
I have been banging my head against this solution all morning, I just cant seem to get it to work.
The following combination of the form_remote_tag, :before, and javascript causes the form to still submit and the action to execute.
Mind to have a look and tell me if I am missing something obvious? I am new to ruby on rails , but relatively adept at javascript, I am hoping I am just doing something blatently wrong .. Thanks! Feel free to email me or I can check back here.
# the form tag
“ValidateForm()”,
:url => { :action => “execute” },
…
) %>
# the javascript
function ValidateForm() {
…
return false
}
September 28, 2006 at 7:34 pm |
your code snippet is a little hard to read, just wanted to make sure you are calling :before => “ValidateForm()” and not just , “ValidateForm()”
October 24, 2006 at 6:13 am |
good site!
November 6, 2006 at 4:42 am |
Thanks Kellybluebook, I’m glad some people are reading it and enjoying it.
September 22, 2007 at 8:01 am |
Hope you come back soon!! notem6715
February 7, 2008 at 11:06 am |
Hi all, by reading the above comments, I thought that you all might have successfully implemented javascript validation before submitting form to a remote action. But when I tried this with my app, I was left unsuccessful.
Below is the code I have.
In my does.rhtml, I am just displaying some text.
this is my javascript code.
When I enter the correct data, the text is getting rendered successfuly but when data is entered incorrectly, the alert message gets displayed and the request is still getting processed and the div is getting updated with the text. Where am I missing the obvious thing? Any help appreciated. thanks in advance.
Can mail the stuff if the code here is obscure.
regards,
venkat
March 19, 2008 at 9:08 am |
Hello!
I think this try.
September 1, 2008 at 5:36 am |
Good day!,
October 22, 2009 at 12:16 pm |
Acceptance of their results relies on the process of obtain- ing the results as well as analysis of the results themselves. ,
October 23, 2009 at 11:06 am |
Short term employment for youth workers, or even job-creation measures that bring in workers without the proper skills to work with youth, can be counter-productive in terms of creating a successful environment for youth participation. ,
March 29, 2010 at 1:53 pm |
My name is Piter Jankovich. oOnly want to tell, that your blog is really cool
And want to ask you: is this blog your hobby?
P.S. Sorry for my bad english
July 5, 2010 at 4:04 pm |
I have my own solution for AJAX validations that I think is quite clean and railsey. I actually put together a screencast on the subject – feel free to check it out at:
http://www.emersonlackey.com/article/rails-ajax-validations-jquery
August 11, 2010 at 12:43 pm |
NOT WORKING…… the request is still getting submitted …
October 6, 2010 at 9:46 am |
On using if (! validate_form()) {return false;} the request is still getting processed
May 22, 2014 at 8:30 pm |
I conceive this website has got some rattling superb info for everyone. Dealing with network executives is like being nibbled to death by ducks. by Eric Sevareid. kkcafdbcbdec