Doubt about RG - what is the best way to control the field?

Asked

Viewed 2,104 times

0

I’m opening this topic to find out how you’ve been working with the issue of RG inclusion in forms.

I think a common concern of all when working with forms is that the control of data is in our hands - and not in the hands of the user.

for this, qto better formatted and controlled each field, better.

One of my big problems is how to control the ID field.

Even so - and for the vast majority of clients I work with, the ID is unnecessary - I somehow end up convincing the client to "ignore" the field in their forms, but now I’m having to work with the ID that is necessary for a client.

Since I don’t have a lot of experience in this I’d like to know how you’ve been working with RG - whether you’re leaving the field open, open or somehow controlling.

From what I’ve seen, read, reli, the best way to control the field is to lock it for only digits - and format it as XXX.XXX.XXX-X - and inform the user that if the digit is "X" (q for what I’ve seen replaces the 10 in the digit) replace with ZERO.

I don’t know if it’s the best shape anyway - and if it will cover 100% of the reality of Rgs.. (the only letter q we have in RG is X in digit?)

My need is not a CHECKER - because this is impossible - but just a control MASK - to avoid completely random data and leave the field as standardized as possible.

the important thing is that the mask is 100% compatible with all types of Rgs.

  • 1

    RG changes from state to state, can not make mask. Or will have to make for each state a different. Also, you will never know if the ID was typed with or without digit. It has a lot of old ID that came without, and with mask the user goes by "normal" number instead of the digit, causing a bad mess. Usually the best thing is to leave free, and just put an extra field to inform the issuing state, and date of issue. If the document is too important, simply Scan.

2 answers

-2

with Masked input vc should use as follows

$("#RG").mask("99.999.999.9?99-*");

so the last field becomes optional and the person can put X if they have.

it is always good you do a validation of RG tbm look this link below for a validator in javascript

http://codigofonte.uol.com.br/codigos/validar-documento-de-identidade-rg

it is always good vc prevent the user from doing "anything", that always of the problem

  • Thanks, @jasar-Orion ! I’ll read the link - just a question, I haven’t tested the mask yet - the mask works with 11 digits + the dv - if the ID has only 9 digits, will it work? And in case you don’t have dv?

  • fix the mask to accept up to 9 digits fixed and 11 optionally. note that everything after ? is optional

  • so that the answer is negative?

  • hi @jasar-Rion, just to clarify that it was not me who denied your answer, alias I never understood what it takes a person to come to a collaborative site, where everyone is donating part of their time to help completely unknown third parties and negativar a response - This goes against everything I imagine of "fair-play", you know? The answer is not offensive, why do it? But I think there are a lot of people out there who think they know everything and should think it’s great to do this kind of thing. A shame..

  • agree , the guy does not respect the goodwill of others, but what counts is that if I helped you or not if I have more doubts warn that I will make the possible appearance to provide some appropriate response.

-2

has this validator that I use

    function validacpf( cpf )
{
  var i;
  s = cpf;
  var c = s.substr(0,9);
  var dv = s.substr(9,2);
  var d1 = 0;
   for (i = 0; i < 9; i++)
  {
    d1 += c.charAt(i)*(10-i);
  }
  if (d1 == 0)
  {
   alert("CPF Invalido");
   return false;
  }
  d1 = 11 - (d1 % 11);
  if (d1 > 9) d1 = 0;
  if (dv.charAt(0) != d1)
  {
   alert("CPF Invalido");
   return false;
  }
  d1 *= 2;
  for (i = 0; i < 9; i++) 
  {
   d1 += c.charAt(i)*(11-i);
  }
  d1 = 11 - (d1 % 11);
  if (d1 > 9) d1 = 0;
  if (dv.charAt(1) != d1)
  {
    alert("CPF Invalido");
    return false;
   }
  return true;
 }
  • Hi @smitherson-da-silva - but is it mod11 ne? From what I saw mod11 does not seem to work with some Rgs issued by some states. Do you know if this is true? (rg is a mess - I saw people complaining about the check by mod 11 - that doesn’t work - but I don’t know how far it is fact or is because the user was using a digit-free ID, for example, as was common in the old days).

  • can not say, I am beginner and always used this script for virtual customer stores and never had problems

Browser other questions tagged

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