Validation field

  • totallnet
  • totallnet's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 322
  • Thank you received: 11

totallnet replied the topic: Validation field

Thanks for reply

This is the script inserted in validation fiels called cnpj
function ff_cnpj_validation(element, message)
{
var cnpj = element.value;

// Elimina CNPJs invalidos conhecidos
if (cnpj == "00000000000000" || 
        cnpj == "11111111111111" || 
        cnpj == "22222222222222" || 
        cnpj == "33333333333333" || 
        cnpj == "44444444444444" || 
        cnpj == "55555555555555" || 
        cnpj == "66666666666666" || 
        cnpj == "77777777777777" || 
        cnpj == "88888888888888" || 
        cnpj == "99999999999999") {
             if (message=='') message ="Informe um CNPJ válido. \n"
             ff_validationFocus(element.name);
             return message;
        }
// Valida DVs
    var tamanho = cnpj.length - 2
    var numeros = cnpj.substring(0,tamanho);
    var digitos = cnpj.substring(tamanho);
    var soma = 0;
    var pos = Number(tamanho) - 7;
    for (i = Number(tamanho) ; i >= 1; i--) {
      soma += numeros.charAt(tamanho - i) * pos--;
      if (pos < 2)
            pos = 9;
    }
    var resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
    if (resultado != digitos.charAt(0))  {
             if (message=='') message ="Informe um CNPJ válido. \n"
             ff_validationFocus(element.name);
             return message;
        }
         
    tamanho = tamanho + 1;
    numeros = cnpj.substring(0,tamanho);
    soma = 0;
    pos = tamanho - 7;
    for (i = tamanho; i >= 1; i--) {
      soma += numeros.charAt(tamanho - i) * pos--;
      if (pos < 2)
            pos = 9;
    }
    resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
    if (resultado != digitos.charAt(1))  {
             if (message=='') message ="Informe um CNPJ válido. \n"
             ff_validationFocus(element.name);
             return message;
        }
    return '';

} // ff_cnpj_validation

And this is my masked input script
echo '<script src="/libraries/maskedinput/src/jquery.maskedinput.js" 
type="text/javascript"></script>';
echo '<script>
jQuery(function($){
     $("#ff_elem49").mask("999.999.999-99");
     $("#ff_elem115").mask("99.999.999/9999-99");
});
</script>';

So with this masked script the validation NOT work... without works.

Kazuo

Kazuo
Level I support
Official Breezing Forms Support
Skype: totallnet 18pm-22pm -3UTC
===============================================
Satisfied? Consider a membership!
===============================================
Follow us on Twitter
===============================================
#232415
  • totallnet
  • totallnet's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 322
  • Thank you received: 11

totallnet replied the topic: Validation field

Here the access datails

This message contains confidential information

Kazuo
Level I support
Official Breezing Forms Support
Skype: totallnet 18pm-22pm -3UTC
===============================================
Satisfied? Consider a membership!
===============================================
Follow us on Twitter
===============================================
#232416
  • Posts: 1465
  • Karma: 48
  • Thank you received: 194

mihaela replied the topic: Validation field

Hello,

Ok, I understand.

So, as I have written, you need to add a JavaScript code to the script that I've sent you to remove all characters except numbers from cnpj variable.
You should add the code after this line:
var cnpj = element.value;

This code will remove the unwanted chars from the number:
cnpj = cnpj.replace(/[^a-zA-Z0-9 ]/g, "");

Let me know whether this works as wanted.

Regards,

Mihaela
#232426
The following user(s) said Thank You: totallnet
  • totallnet
  • totallnet's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 322
  • Thank you received: 11

totallnet replied the topic: Validation field

Works. thank you

Kazuo
Level I support
Official Breezing Forms Support
Skype: totallnet 18pm-22pm -3UTC
===============================================
Satisfied? Consider a membership!
===============================================
Follow us on Twitter
===============================================
#232436
  • Posts: 1465
  • Karma: 48
  • Thank you received: 194

mihaela replied the topic: Validation field

Great!

I'm glad that it works.

Regards,

Mihaela
#232549
Moderators: ForumSupporttomeperica
Time to create page: 0.071 seconds

New Support System

Dear Customers,

Users with active subscription have support priority which will be dona via ServiceDesk (My Account > Raise a ticket).
FREE Support topics will be answered when AND if there is time.

You can check support guidelines here : here

Regards,
Crosstec Team

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99€

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here