what's the deal with blank? function anyway?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

what's the deal with blank? function anyway?

fugee ohu
is this a better way to check for empty form field inputs than trim and val combined?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/77bb0568-31f0-4804-a4ff-7734527d063e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: what's the deal with blank? function anyway?

Walter Lee Davis
You seem to be comparing apples and oranges here. val() is from jQuery and trim() is from JavaScript. #blank? is from Rails (not Ruby). Which one or combination you might use are entirely up to you, and depend on your use-case.

If you want to provide a convenience to your users, and are helping them avoid entering missing or malformed data (but critically, are not relying on this protection to be complete or even present, since JavaScript can be turned off in a browser), then by all means use trim and val and have fun.

If you are going to rely on the data being present before you create a new record in your database, then you had best be using Ruby (and the language extensions Rails provides to it) to do that.

The professional solution would be to use both, so that you can be helpful AND safe.

Walter

> On Apr 1, 2017, at 4:19 PM, fugee ohu <[hidden email]> wrote:
>
> is this a better way to check for empty form field inputs than trim and val combined?
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/77bb0568-31f0-4804-a4ff-7734527d063e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/EE461E97-5006-40FF-9B1E-8A356025B4CE%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: what's the deal with blank? function anyway?

fugee ohu
There's also jquery-validates.js

On Sunday, April 2, 2017 at 10:40:50 AM UTC-4, Walter Lee Davis wrote:
You seem to be comparing apples and oranges here. val() is from jQuery and trim() is from JavaScript. #blank? is from Rails (not Ruby). Which one or combination you might use are entirely up to you, and depend on your use-case.

If you want to provide a convenience to your users, and are helping them avoid entering missing or malformed data (but critically, are not relying on this protection to be complete or even present, since JavaScript can be turned off in a browser), then by all means use trim and val and have fun.

If you are going to rely on the data being present before you create a new record in your database, then you had best be using Ruby (and the language extensions Rails provides to it) to do that.

The professional solution would be to use both, so that you can be helpful AND safe.

Walter

> On Apr 1, 2017, at 4:19 PM, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="5qob5g21AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:
>
> is this a better way to check for empty form field inputs than trim and val combined?
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="5qob5g21AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="5qob5g21AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/77bb0568-31f0-4804-a4ff-7734527d063e%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/77bb0568-31f0-4804-a4ff-7734527d063e%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/77bb0568-31f0-4804-a4ff-7734527d063e%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/77bb0568-31f0-4804-a4ff-7734527d063e%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b9797925-d18f-46d4-9233-8a4137b51183%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.