views:

301

answers:

2

I want to only show the last four digits of a Social security number after they leave the textbox. Does AJax have a tool for this that I am not aware of? How can i do this? I want to replace the digits with '*'. I'm working in .NET. Ajax is also accessible.

+1  A: 
var el = document.getElementById('MyTextBoxId');
el.value = '***-**-' + (el.value.replace(/-/g,'') % 10000);

You probably also want a separate hidden input to save the original data...

Joel Coehoorn
+3  A: 

To my knowledge, there isn't a control that does this in the ASP.NET AJAX library, but the way we handle it is to use three text boxes separated by labels containing dashes. The first two are password boxes and the last one is a normal text box. It's kind of ghetto, but it works.

Correl
That's actually a rather nifty way of handling it.
ceejayoz
i like the idea. Thanks. If i wouldnt have the ajax validation in place i would use this ghetto idea. Thanks correl
Eric