cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="container">
  <div class="row">

    <div class="col-lg-4 col-lg-offset-4 col-md-6 col-md-offset-3 col-sm-10 col-sm-offset-1">
      <h3>TC ID</h3>
      <div class="form-group">
        <input id="tc" type="tel" class="input-lg form-control" autocomplete="off" placeholder="12345678901">
      </div>
      <h4 class="text-uppercase text-danger"></h4>
    </div><!-- "col-xs-12" -->

  </div><!-- "row" -->
</div><!-- "container" -->
            
          
!
            
                    $("document").ready(function() {

        var checkTcNum = function(value) {
          value = value.toString();
          var isEleven = /^[0-9]{11}$/.test(value);
          var totalX = 0;
          for (var i = 0; i < 10; i++) {
            totalX += Number(value.substr(i, 1));
          }
          var isRuleX = totalX % 10 == value.substr(10,1);
          var totalY1 = 0;
          var totalY2 = 0;
          for (var i = 0; i < 10; i+=2) {
            totalY1 += Number(value.substr(i, 1));
          }
          for (var i = 1; i < 10; i+=2) {
            totalY2 += Number(value.substr(i, 1));
          }
          var isRuleY = ((totalY1 * 7) - totalY2) % 10 == value.substr(9,0);
          return isEleven && isRuleX && isRuleY;
        };


        $('#tc').on('keyup focus blur load', function(event) {
          event.preventDefault();
          var isValid = checkTcNum($(this).val());
          console.log('isValid ' , isValid);
          if (isValid) {
            $('h4').text("TRUE").attr('class', 'text-uppercase text-success');
          }
          else {
            $('h4').text("FALSE").attr('class', 'text-uppercase text-danger');
          }
        });
      }); //document.ready
            
          
!
999px
Loading ..................

Console