# Password\_field helper

**URL:** <https://www.ruby-forum.com/t/password-field-helper/109249>\
**Category:** Rails\
**Created:** [July 12, 2007, 7:17pm UTC](https://www.ruby-forum.com/t/password-field-helper/109249 "2007-07-12T19:17:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [July 12, 2007, 7:17pm UTC](https://www.ruby-forum.com/t/password-field-helper/109249/1 "2007-07-12T19:17:56Z")

</div>

I am using a password\_field help to collect credit card information. Is  
there a way to make it so the field collects no more then 16 digits? In  
normal html this would be achieved through “nowrap.” Is there an  
equivalent in the rails world?

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [July 12, 2007, 7:21pm UTC](https://www.ruby-forum.com/t/password-field-helper/109249/2 "2007-07-12T19:21:03Z")

</div>

Shandy N. wrote:

> I am using a password\_field help to collect credit card information. Is  
> there a way to make it so the field collects no more then 16 digits? In  
> normal html this would be achieved through “nowrap.” Is there an  
> equivalent in the rails world?

I should give the code that I have so far, so here it is:

\<%= password\_field ‘creditcard’, ‘card\_num’, :id =\> ‘card\_num’,  
:cols=\>16 %\>

Thanks,

~S

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [July 12, 2007, 7:59pm UTC](https://www.ruby-forum.com/t/password-field-helper/109249/3 "2007-07-12T19:59:59Z")

</div>

you’re using a password field for a credit card number? Won’t that  
make it difficult for the user to see what they’re typing?

Mike

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [July 12, 2007, 9:06pm UTC](https://www.ruby-forum.com/t/password-field-helper/109249/4 "2007-07-12T21:06:52Z")

</div>

Mike G. wrote:

> you’re using a password field for a credit card number? Won’t that  
> make it difficult for the user to see what they’re typing?
> 
> Mike

That’s kind of the idea…It’s like when you type in your password  
into your yahoo! account is shows astericks so someone that is looking  
over your shoulder can’t see your password. It’s the same idea here.

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [July 12, 2007, 9:21pm UTC](https://www.ruby-forum.com/t/password-field-helper/109249/5 "2007-07-12T21:21:10Z")

</div>

I don’t think that’s such a great idea… First off, I don’t know about  
you, but I don’t have my credit card memorized, which means when I’m  
buying something, I’ve gotta take out my credit card and read off the  
digits while I type them into the entry box. If anyone wanted to see  
my credit card number, all they’d have to do is look at my credit card  
as it’s lying on my desk - the fact that you use a password\_field to  
hide the information will be of little use, and will most likely just  
annoy your users. It means they’ve gotta type their credit card  
number in _exactly_ without making a mistake, and can’t re-read it to  
make sure they’ve entered it correctly.

Ever notice how password fields usually have a confirmation box?  
Since you can’t see what you’re typing, it makes it easy to make a  
mistake. By making the user type in their password twice, it helps  
eliminate any typos. But of course you wouldn’t want to do the same  
thing with a credit card entry box. Typing in your credit card number  
once is bad enough, if I had to do it twice, I’d just as soon go to  
another website.

Mike
