Validate input against a field in other table

  • Posts: 6478
  • Karma: 170
  • Thank you received: 667

tomeperica replied the topic: Validate input against a field in other table

Hey there,

sry for a delay, huge workload we have on forum :blush: I have complete your request, follow steps below to install the form and make it work.

First thing you need to create is database table called serials, in screenshot you can see how I created mine in phpMyAdmin(2 images attached below).

When you are done with filling results unzip ProductREgistration_Package and you will see 2 files, package form and serials.php file. Put serials.php file into your server root where joomla is installed. Install AJAX_SerialReg.xml form via Package Installer, open up the installed form and go to Serial number element -> Advanced tab -> Action Script and change url path for serials.php file from
http://localhost/joomla/serials.php
to
http://yourdomain.com/serials.php
you can see there is AJAX code which will pull values from serials.php file.

Test your form with serial numbers you entered into your custom created table(you can for example put same as I did).

You can see if you click on submit without entering any value into Serial field valdation will popup, if you enter wrong number again validation will trigger. Code for that validation is in Serial number element -> Validation:
function ff_serial_validation(element, message)
{
   if(ff_valuenotempty(element, message) != '') return 'Please enter serial number';
    var myreturn = '';
    JQuery.ajaxSetup({async:false});
    JQuery.post('index.php', { option: 'com_breezingforms', ff_form: ff_processor.form, Itemid: 0, format: 'html', serial: element.value }, function(data){console.log(data);    if( data != '1' ){ message == '' ? myreturn = 'This serial number is not valid for your product!' : myreturn = message; } } );
 return myreturn;
} // ff_serial_validation

and crucial one is in Form Pieces -> Before Form -> Custom
if( JRequest::getVar('serial', null) !== null ){
while (@ob_get_level() > 0) {
@ob_end_clean();
}
   $db = JFactory::getDBO();
   $db->setQuery("Select `serial` From serials Where `serial` = " . $db->Quote(JRequest::getVar('serial', null)));
   if(trim($db->loadResult())){
     echo 1;
   } else {
     echo 0;
   }
   exit;
}

That's it in general, I hope this will work for you.

Let me know the result.

Regards,
Tome

Regards,
Tome
==========================================
Need to renew Pro Support?
Buy Here!
==========================================
Satisfied?
Consider a membership!
==========================================
Like us on Facebook
==========================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
#195703
Attachments:
The following user(s) said Thank You: rimartin
  • rimartin
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0

rimartin replied the topic: Validate input against a field in other table

Hello Tome,

Thank you very much for your help. I'm gonna implement it and will give you a feedback.

Regards,

Richard
#195742
  • Posts: 6478
  • Karma: 170
  • Thank you received: 667

tomeperica replied the topic: Validate input against a field in other table

Cool!

Let me know the result.

Regards,
Tome

Regards,
Tome
==========================================
Need to renew Pro Support?
Buy Here!
==========================================
Satisfied?
Consider a membership!
==========================================
Like us on Facebook
==========================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
#195773
Moderators: ForumSupporttomeperica
Time to create page: 0.067 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription 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 for just 49! (Summer Sale)

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!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the 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