Validate data in form

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

totallnet replied the topic: Validate data in form

I have the above script validation too... so in code framework in put the unique validation first than my custom validation.. and now its working

Thanks again

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

mihaela replied the topic: Validate data in form

Great! I'm glad that you've managed to make it work for your form.

Regards,

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

totallnet replied the topic: Validate data in form

Hi..

How can i prevent user insert sequential number (111111111111) in this code:
function ff_cpf_validation(element, message)
{

    var myreturn = '';
    JQuery.ajaxSetup({async:false});
    JQuery.post('index.php', { option: 'com_breezingforms', ff_form: ff_processor.form, Itemid: 0, format: 'html', cpf: element.value }, function(data){ if( data != '1' ){ message == '' ? myreturn = 'CPF já cadastrado!' : myreturn = message; } } );
    return myreturn;

var tmp = jQuery.trim(element.value);
    tmp = tmp.replace('.','');
	tmp= tmp.replace('.','');
	cpf = tmp.replace('-','');
	while(cpf.length < 11) cpf = "0"+ cpf;
	var expReg = /^0+$|^1+$|^2+$|^3+$|^4+$|^5+$|^6+$|^7+$|^8+$|^9+$/;
	var a = [];
	var b = new Number;
	var c = 11;
	for (i=0; i<11; i++){
		a[i] = cpf.charAt(i);
		if (i < 9) b += (a[i] * --c);
	}
	if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
	b = 0;
	c = 11;
	for (y=0; y<10; y++) b += (a[y] * c--);
	if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
	
	var retorno = true;
	if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10]) || cpf.match(expReg)) retorno = false;
	

    if (!retorno) {
        if (message=='') message ="Informe um CPF válido. \n"
        ff_validationFocus(element.name);
        return message;
    } // if
    return '';

} // ff_cpf_validation

Thanks in advance

Kazuo

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

mihaela replied the topic: Validate data in form

Hello again,

Here is the code that will check if sequential number is entered:
function ff_cpf_validation(element, message)
{

    var myreturn = '';
    JQuery.ajaxSetup({async:false});
    JQuery.post('index.php', { option: 'com_breezingforms', ff_form: ff_processor.form, Itemid: 0, format: 'html', cpf: element.value }, function(data){ if( data != '1' ){ message == '' ? myreturn = 'CPF já cadastrado!' : myreturn = message; } } );
    return myreturn;

var tmp = jQuery.trim(element.value);
    tmp = tmp.replace('.','');
	tmp= tmp.replace('.','');
	cpf = tmp.replace('-','');

	if (cpf == "00000000000000" || 
        cpf == "11111111111111" || 
        cpf == "22222222222222" || 
        cpf == "33333333333333" || 
        cpf == "44444444444444" || 
        cpf == "55555555555555" || 
        cpf == "66666666666666" || 
        cpf == "77777777777777" || 
        cpf == "88888888888888" || 
        cpf == "99999999999999") {
        if (message=='') message ="Informe um CPF válido. \n"
        ff_validationFocus(element.name);
        return message;
    }


	while(cpf.length < 11) cpf = "0"+ cpf;
	var expReg = /^0+$|^1+$|^2+$|^3+$|^4+$|^5+$|^6+$|^7+$|^8+$|^9+$/;
	var a = [];
	var b = new Number;
	var c = 11;
	for (i=0; i<11; i++){
		a[i] = cpf.charAt(i);
		if (i < 9) b += (a[i] * --c);
	}
	if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
	b = 0;
	c = 11;
	for (y=0; y<10; y++) b += (a[y] * c--);
	if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
	
	var retorno = true;
	if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10]) || cpf.match(expReg)) retorno = false;
	

    if (!retorno) {
        if (message=='') message ="Informe um CPF válido. \n"
        ff_validationFocus(element.name);
        return message;
    } // if
    return '';

} // ff_cpf_validation

Let me know whether it works as you wanted.

Regards,

Mihaela
#232548
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