How to pass the original value and not the replace number ( * ) The Next CEO of Stack OverflowWhat are valid values for the id attribute in HTML?How do I enumerate an enum in C#?How to horizontally center a <div>?Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?How do I check if an element is hidden in jQuery?What are the correct version numbers for C#?How do I redirect to another webpage?How can I know which radio button is selected via jQuery?How to check whether a checkbox is checked in jQuery?How do I generate a random int number?

Horror film about a man brought out of cryogenic suspension without a soul, around 1990

Why can't we say "I have been having a dog"?

What did the word "leisure" mean in late 18th Century usage?

Upgrading From a 9 Speed Sora Derailleur?

Is it a bad idea to plug the other end of ESD strap to wall ground?

MT "will strike" & LXX "will watch carefully" (Gen 3:15)?

What happens if you break a law in another country outside of that country?

Man transported from Alternate World into ours by a Neutrino Detector

Strange use of "whether ... than ..." in official text

Another proof that dividing by 0 does not exist -- is it right?

Car headlights in a world without electricity

Calculate the Mean mean of two numbers

Masking layers by a vector polygon layer in QGIS

Salesforce opportunity stages

How to show a landlord what we have in savings?

Simplify trigonometric expression using trigonometric identities

Small nick on power cord from an electric alarm clock, and copper wiring exposed but intact

Is it okay to majorly distort historical facts while writing a fiction story?

Calculating discount not working

How do I keep Mac Emacs from trapping M-`?

Can this transistor (2n2222) take 6V on emitter-base? Am I reading datasheet incorrectly?

Direct Implications Between USA and UK in Event of No-Deal Brexit

How do I secure a TV wall mount?

pgfplots: How to draw a tangent graph below two others?



How to pass the original value and not the replace number ( * )



The Next CEO of Stack OverflowWhat are valid values for the id attribute in HTML?How do I enumerate an enum in C#?How to horizontally center a <div>?Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?How do I check if an element is hidden in jQuery?What are the correct version numbers for C#?How do I redirect to another webpage?How can I know which radio button is selected via jQuery?How to check whether a checkbox is checked in jQuery?How do I generate a random int number?










0















I mask the numbers of SSN obviously for security... but when I submit, the variable fill with "*--****" and is suppose to grab the original input ex. 123-45-6789. I just want to mask that input.



JQuery:



$(function () 
$('#ssn').keyup(function ()
var val = this.value.replace(/[^d*]/g, '').replace(/d/g, '*');
var newVal = '';
var sizes = [3, 2, 4];
var maxSize = 10;

for (var i in sizes)
if (val.length > sizes[i])
newVal += val.substr(0, sizes[i]) + '-';
val = val.substr(sizes[i]);
else
break;


newVal += val;
this.value = newVal;
);
);


HTML:



<div class="col-lg-3 col-md-4">
@Html.LabelFor(model => model.SolicitantDataView.SSN, htmlAttributes: new @class = "control-label col-lg-12 col-md-3 required" )

@Html.EditorFor(model => model.SolicitantDataView.SSN, new htmlAttributes = new @class = "form-control ssn ssnControl", @id = "ssn", @maxlength = "11" )
@Html.ValidationMessageFor(model => model.SolicitantDataView.SSN, "", new @class = "text-danger" )
</div>


I try this way but the require method not work anymore...



 $(document).ready(function()
$('.ssn').unmask().maskSSN('999-99-9999', maskedChar: 'X', maskedCharsLength: 5 );
);









share|improve this question




























    0















    I mask the numbers of SSN obviously for security... but when I submit, the variable fill with "*--****" and is suppose to grab the original input ex. 123-45-6789. I just want to mask that input.



    JQuery:



    $(function () 
    $('#ssn').keyup(function ()
    var val = this.value.replace(/[^d*]/g, '').replace(/d/g, '*');
    var newVal = '';
    var sizes = [3, 2, 4];
    var maxSize = 10;

    for (var i in sizes)
    if (val.length > sizes[i])
    newVal += val.substr(0, sizes[i]) + '-';
    val = val.substr(sizes[i]);
    else
    break;


    newVal += val;
    this.value = newVal;
    );
    );


    HTML:



    <div class="col-lg-3 col-md-4">
    @Html.LabelFor(model => model.SolicitantDataView.SSN, htmlAttributes: new @class = "control-label col-lg-12 col-md-3 required" )

    @Html.EditorFor(model => model.SolicitantDataView.SSN, new htmlAttributes = new @class = "form-control ssn ssnControl", @id = "ssn", @maxlength = "11" )
    @Html.ValidationMessageFor(model => model.SolicitantDataView.SSN, "", new @class = "text-danger" )
    </div>


    I try this way but the require method not work anymore...



     $(document).ready(function()
    $('.ssn').unmask().maskSSN('999-99-9999', maskedChar: 'X', maskedCharsLength: 5 );
    );









    share|improve this question


























      0












      0








      0








      I mask the numbers of SSN obviously for security... but when I submit, the variable fill with "*--****" and is suppose to grab the original input ex. 123-45-6789. I just want to mask that input.



      JQuery:



      $(function () 
      $('#ssn').keyup(function ()
      var val = this.value.replace(/[^d*]/g, '').replace(/d/g, '*');
      var newVal = '';
      var sizes = [3, 2, 4];
      var maxSize = 10;

      for (var i in sizes)
      if (val.length > sizes[i])
      newVal += val.substr(0, sizes[i]) + '-';
      val = val.substr(sizes[i]);
      else
      break;


      newVal += val;
      this.value = newVal;
      );
      );


      HTML:



      <div class="col-lg-3 col-md-4">
      @Html.LabelFor(model => model.SolicitantDataView.SSN, htmlAttributes: new @class = "control-label col-lg-12 col-md-3 required" )

      @Html.EditorFor(model => model.SolicitantDataView.SSN, new htmlAttributes = new @class = "form-control ssn ssnControl", @id = "ssn", @maxlength = "11" )
      @Html.ValidationMessageFor(model => model.SolicitantDataView.SSN, "", new @class = "text-danger" )
      </div>


      I try this way but the require method not work anymore...



       $(document).ready(function()
      $('.ssn').unmask().maskSSN('999-99-9999', maskedChar: 'X', maskedCharsLength: 5 );
      );









      share|improve this question
















      I mask the numbers of SSN obviously for security... but when I submit, the variable fill with "*--****" and is suppose to grab the original input ex. 123-45-6789. I just want to mask that input.



      JQuery:



      $(function () 
      $('#ssn').keyup(function ()
      var val = this.value.replace(/[^d*]/g, '').replace(/d/g, '*');
      var newVal = '';
      var sizes = [3, 2, 4];
      var maxSize = 10;

      for (var i in sizes)
      if (val.length > sizes[i])
      newVal += val.substr(0, sizes[i]) + '-';
      val = val.substr(sizes[i]);
      else
      break;


      newVal += val;
      this.value = newVal;
      );
      );


      HTML:



      <div class="col-lg-3 col-md-4">
      @Html.LabelFor(model => model.SolicitantDataView.SSN, htmlAttributes: new @class = "control-label col-lg-12 col-md-3 required" )

      @Html.EditorFor(model => model.SolicitantDataView.SSN, new htmlAttributes = new @class = "form-control ssn ssnControl", @id = "ssn", @maxlength = "11" )
      @Html.ValidationMessageFor(model => model.SolicitantDataView.SSN, "", new @class = "text-danger" )
      </div>


      I try this way but the require method not work anymore...



       $(document).ready(function()
      $('.ssn').unmask().maskSSN('999-99-9999', maskedChar: 'X', maskedCharsLength: 5 );
      );






      c# jquery html asp.net-mvc






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 20:43







      Jonathan Padilla

















      asked Mar 8 at 19:13









      Jonathan PadillaJonathan Padilla

      337




      337






















          1 Answer
          1






          active

          oldest

          votes


















          0














          By replace() ing the val, you override the original typed data. That's why you get only asterisks. A simple aproach would be using a hidden control input, in which you store the typed value before masking. But the right thing to do is to use a js mask extension which supports SSN (or, even better, a custom mask).






          share|improve this answer























          • can you explain with a example, I'm new at js =/

            – Jonathan Padilla
            Mar 8 at 20:03











          • I do it like this way $(document).ready(function() $('.ssn').unmask().maskSSN('999-99-9999', maskedChar: 'X', maskedCharsLength: 5 ); ); but the require gone... why?

            – Jonathan Padilla
            Mar 8 at 20:42











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55069568%2fhow-to-pass-the-original-value-and-not-the-replace-number%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          By replace() ing the val, you override the original typed data. That's why you get only asterisks. A simple aproach would be using a hidden control input, in which you store the typed value before masking. But the right thing to do is to use a js mask extension which supports SSN (or, even better, a custom mask).






          share|improve this answer























          • can you explain with a example, I'm new at js =/

            – Jonathan Padilla
            Mar 8 at 20:03











          • I do it like this way $(document).ready(function() $('.ssn').unmask().maskSSN('999-99-9999', maskedChar: 'X', maskedCharsLength: 5 ); ); but the require gone... why?

            – Jonathan Padilla
            Mar 8 at 20:42















          0














          By replace() ing the val, you override the original typed data. That's why you get only asterisks. A simple aproach would be using a hidden control input, in which you store the typed value before masking. But the right thing to do is to use a js mask extension which supports SSN (or, even better, a custom mask).






          share|improve this answer























          • can you explain with a example, I'm new at js =/

            – Jonathan Padilla
            Mar 8 at 20:03











          • I do it like this way $(document).ready(function() $('.ssn').unmask().maskSSN('999-99-9999', maskedChar: 'X', maskedCharsLength: 5 ); ); but the require gone... why?

            – Jonathan Padilla
            Mar 8 at 20:42













          0












          0








          0







          By replace() ing the val, you override the original typed data. That's why you get only asterisks. A simple aproach would be using a hidden control input, in which you store the typed value before masking. But the right thing to do is to use a js mask extension which supports SSN (or, even better, a custom mask).






          share|improve this answer













          By replace() ing the val, you override the original typed data. That's why you get only asterisks. A simple aproach would be using a hidden control input, in which you store the typed value before masking. But the right thing to do is to use a js mask extension which supports SSN (or, even better, a custom mask).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 19:39









          Igor AraújoIgor Araújo

          1




          1












          • can you explain with a example, I'm new at js =/

            – Jonathan Padilla
            Mar 8 at 20:03











          • I do it like this way $(document).ready(function() $('.ssn').unmask().maskSSN('999-99-9999', maskedChar: 'X', maskedCharsLength: 5 ); ); but the require gone... why?

            – Jonathan Padilla
            Mar 8 at 20:42

















          • can you explain with a example, I'm new at js =/

            – Jonathan Padilla
            Mar 8 at 20:03











          • I do it like this way $(document).ready(function() $('.ssn').unmask().maskSSN('999-99-9999', maskedChar: 'X', maskedCharsLength: 5 ); ); but the require gone... why?

            – Jonathan Padilla
            Mar 8 at 20:42
















          can you explain with a example, I'm new at js =/

          – Jonathan Padilla
          Mar 8 at 20:03





          can you explain with a example, I'm new at js =/

          – Jonathan Padilla
          Mar 8 at 20:03













          I do it like this way $(document).ready(function() $('.ssn').unmask().maskSSN('999-99-9999', maskedChar: 'X', maskedCharsLength: 5 ); ); but the require gone... why?

          – Jonathan Padilla
          Mar 8 at 20:42





          I do it like this way $(document).ready(function() $('.ssn').unmask().maskSSN('999-99-9999', maskedChar: 'X', maskedCharsLength: 5 ); ); but the require gone... why?

          – Jonathan Padilla
          Mar 8 at 20:42



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55069568%2fhow-to-pass-the-original-value-and-not-the-replace-number%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

          List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229