Akhter HUssain

Akhter HUssain

  • 720
  • 1.3k
  • 102.1k

Textbox input character pattern?

Sep 11 2019 5:28 AM
i want textbox input pattern like this (1111-111111-5254) and i used this code ,means that when i select row from gridview for editing then in popup window textbox show(-) ,but below code is not working
  1. //CNIC  
  2.           $("#txtCNIC").attr('maxlength''16');  
  3.                $('#txtCNIC').on('keyup'function () {  
  4.                    var inp = $('#txtCNIC').val();  
  5.                    var noinp = inp.split('-').join('');  
  6.                    if (noinp.length > 4 && noinp.length <= 10) {  
  7.                        $('#txtCNIC').val(noinp.substring(0, 4) + '-' + noinp.substring(4, noinp.length));  
  8.                    } else if (noinp.length > 10 && noinp.length <= 14) {  
  9.                        $('#txtCNIC').val(inp.substring(0, 11) + "-" + noinp.substring(10, noinp.length));  
  10.                    }  
  11.            });  
 

Answers (2)