GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes confusing problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "confusing problem" Watch "confusing problem" New topic
Author

confusing problem

james rickards
Greenhorn

Joined: Apr 23, 2014
Posts: 2
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

Joined: Sep 13, 2007
Posts: 2452
    
    8

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.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Rob Crowther
author
Ranch Hand

Joined: Nov 06, 2012
Posts: 296
    
    5

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?


Read my books: Hello! HTML5 & CSS3 | HTML5 in Action | Read my blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: confusing problem