Preg match in Jquery

CHECK EXPRESSION LIKE:: 11112233-1234


<input type="text" value="" name="preg" id="preg"  placeholder="11112233-1234" form-control">

<script type="text/javascript">
$('#preg').on('keyup', function(){

   var dis = $(this);

   var _preg = "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][-][0-9][0-9][0-9][0-9]";

   if(dis.val().match(/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][-][0-9][0-9][0-9][0-9]/)){

       console.log('Matched');
   }else{
       console.log('Not-Matched');
   }
});
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *