Jquery - RG mask

Asked

Viewed 973 times

0

I am having problems creating a mask with Jquery, because there are rg’s that close with the 'X' type'.

HTML

<input name="rg" class="form-control" id="rg" pattern="^(d{3}\.d{3}\.d{3}\-d{2}" max='11'>

Script

<script type="text/javascript">$(document).ready(function(){
  $("#rg").mask("999.999.999-99" || "999.999.999-a");});  
</script>

I cannot put the 'or' condition to accept more than one mask as an alternative.

  • 2

    Impossible the CPF to finish in digit. You must be confusing with some R.G. By the formula of the CPF, only numbers are accepted.

  • is ID same guy...

  • 2

    RG changes format in each state. It is not that simple. You would have to assemble several combinations.

  • It’s a CPF or ID mask?

  • 1

    It’s an ID mask

  • 2

    RG, for a range of reasons, usually has no mask. What is actually used is an expression for formatting, depending on the typing. Your reply, as @Bacco said, is answered at this link: Regular Expression for RG

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.