JavaScript Social Security Number input validation social security number format,social security number suspended,social security

I have this sample:

link

CODE HTML:

<input class="required-input" id="ssn" maxlength="9" type="text" name="ssn" placeholder="123-45-6789">

CODE CSS:

.valid{
  border:1px solid blue;
}
.invalid{
  border:1px solid red;
}

CODE JS:

function ssnFormat(){
    $("#ssn").on('blur change', function () {
        text = $(this).val().replace(/(\d{3})(\d{2})(\d{4})/, "$3-$2-$4");
        if ($(this).val() == '' || $(this).val().match(text) || $(this).val().length == 0) {
            $(this).removeClass('valid').addClass('invalid');
        }else {
            $(this).removeClass('invalid').addClass('valid');
        }
    });
}

$( "#ssn" ).on('blur change', function() {
        ssnFormat();
    });

What I want to do these things are:

1.If I write the following text I want to validate this format 123-12-1234

2.If I write 123456789 I want to transform when click outside input in this format

123-12-1234

I tried to do this by using the function below but don't work

$("#ssn").on("click", function() {
        var thisVal = $(this).val();
        var value = thisVal.replace(/[^\/\d]/g,''); //here is a problem
        $(this).val(value);
    });

Can you please help me solve this problem?

Thanks in advance!

Answer:1

I am trying to animate a div upwards when a user hovers on the div. I am able to animate the div making it bigger, however the animation happens downwards. I am trying to keep the bottom of the div ...

I am trying to animate a div upwards when a user hovers on the div. I am able to animate the div making it bigger, however the animation happens downwards. I am trying to keep the bottom of the div ...

  1. make eraser bigger in animate

The question is simple, but can't really find an answer. How to simulate the drag & drop events using chrome developer tools ? sure i can manually drag & drop the file, but then i can't ...

The question is simple, but can't really find an answer. How to simulate the drag & drop events using chrome developer tools ? sure i can manually drag & drop the file, but then i can't ...

  1. google chrome developer tools
  2. google chrome developer dashboard
  3. google chrome developer console
  4. google chrome developer edition
  5. google chrome developer tools shortcut
  6. google chrome developer settings
  7. google chrome developer tools mobile
  8. google chrome developer tools disabled
  9. google chrome developer channel
  10. google chrome developer tools view cookies
  11. google chrome developer tools color picker
  12. google chrome developer tools mobile view
  13. google chrome developer extensions
  14. google chrome developer tools dark theme
  15. google chrome developer support
  16. google chrome developer tools network tab
  17. google chrome developer tools not working
  18. google chrome developer tools disable cache
  19. google chrome developer tools iphone
  20. google chrome developer tools crash course

Given an <input id="foo"> element, I want to call an existing function on blur and pass an anonymous callback to it. Case 1, simple function call: function bar(){ alert("I am"); } $("#...

Given an <input id="foo"> element, I want to call an existing function on blur and pass an anonymous callback to it. Case 1, simple function call: function bar(){ alert("I am"); } $("#...

  1. passing anonymous functions in matlab
  2. passing anonymous functions javascript
  3. passing parameters to anonymous functions javascript
  4. passing arguments to anonymous functions javascript

It is one of the challenge in the book I fail to understand, or my brain is unable to break it down. Here is the solution function: function arrayToList(array) { var list = null; for (var i = ...

It is one of the challenge in the book I fail to understand, or my brain is unable to break it down. Here is the solution function: function arrayToList(array) { var list = null; for (var i = ...

  1. converting array to linked list java
  2. convert array to linked list c++
  3. convert array to linked list
  4. convert array to linked list python
  5. convert array to linked list javascript
  6. convert array into linked list
  7. convert array into linked list java
  8. convert array into linked list c++