Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

confusing problem

 
james rickards
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Do you know how to format the output of something in JS? For example, if you want to show the social security number of someone, which is nine digits long, but you want to mask the first 5 digits and only show the last 4, BUT when they hit save, you want the original numbers saved, not the * or the #.

So if someones social security number is 123-45-6789, you want it to show ***-**-6789, but if they hit save, it saves 123456789 to the database.

I can make the JSP side show this properly and have made it read only, but then the problem is that when I hit submit, I get an error saying that the field is incomplete, so I would need to send the information already stored for the path in the jsp.

thanks
 
K. Tsang
Bartender
Posts: 3445
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah yes read-only and disabled form fields can't be fetched when html forms submit. Like you have experienced.

What you should do in such case is have hidden fields storing the actual not encrypted/formatted value. Then in your code fetch this hidden field instead.

Of course if such hidden values need updating, jquery should do the trick when cursor leaves the text field (lose focus) or something.

Hope this helps.
 
Rob Crowther
author
Ranch Hand
Posts: 297
5
Android Fedora Firefox Browser
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think if you're at all concerned about the security of someone's social security number then you shouldn't be sending it with the web page in the first place. What is the scenario you're trying to protect against by hiding some but not all of it? What does the user gain by being able to edit the field?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic