Age restriction

Here it is explained how to allow only people of legal age to submit the form.

In this example, it is assumed that "%d/%m/%Y" date format is used.

To make it able only for people of legal age to submit a form follow these steps:

1) Create a "Calendar" element with format "%d/%m/%Y".

2) Go to Properties of that calendar element, scroll down and in the "Validation" section check the "Required" checkbox, set Type to "Custom".

In the code area that appears below paste the following code:

function ff_CalendarElementName_validation(element, message)
{
   // Checking if the entered date is in right format
   var pattern = /[0-3][0-9]\/(0|1)[0-9]\/(19|20)[0-9]{2}/;
   if(pattern.test(element.value))
   {
      var date_array = element.value.split('/');
      var day = date_array[0];

      // Attention! Javascript consider months in the range 0 - 11
      var month = date_array[1] - 1;
      var year = date_array[2];

      // This instruction will create a date object
      birthDate = new Date(year,month,day);

      if(year != birthDate.getFullYear())
      {
         return message == '' ? "Date isn't entered in the right format.\n" : message;
      }

      if(month != birthDate.getMonth())
      {
         return message == '' ? "Date isn't entered in the right format.\n" : message;
      }

      if(day != birthDate.getDate())
      {
         return message == '' ? "Date isn't entered in the right format.\n" : message;
      }
   }
   else
   {
      return message == '' ? "Date isn't entered in the right format.\n" : message;
   }
   
   var now = new Date();
     
   var dobYear = birthDate.getFullYear();
   var dobMonth = birthDate.getMonth();
   var dobDay = birthDate.getDate()

   var age = now.getFullYear() - dobYear;
   var ageMonth = now.getMonth() - dobMonth;
   var ageDay = now.getDate() - dobDay;

   if (ageMonth < 0 || (ageMonth == 0 && ageDay < 0)){
       age = parseInt(age) - 1;
   }

   if (age < 18) {
       if (message=='') message = "Only persons of legal age can submit this form.\n"
       ff_validationFocus(element.name);
       return message;
   } // if
   else if (age  >= 18){ 
       return '';
   }
    
} // ff_CalendarElementName_validation

 

NOTE: In the code above you have to replace "CalendarElementName" with the name of that calendar element in your form.

This way, an error message will appear after clicking on the submit button if the age of the person isn't above 18.

Therefore, only users of legal age will be able to submit the form.

 

Add a comment

Top 5 Joomla!® 2019 Forms Extensions

Though we develop our own popular Joomla!® forms extension BreezingForms, it is always good to know that there are alternatives. I would like to introduce you some of the other major Joomla!® forms extensions that I think are definitive worth to have a look at 2019-

1. JSN Uniform

JSN UniForm is a Joomla! Form extension which helps you create forms quickly and easily - from normal to complex.
Moreover, you can efficiently manage all the submissions as the administrator. The configured form can be published in any part of the website including: in article content, in the main body area and different module positions.

JSN Unifiorm

2. RSForm

RSForm! is a general Joomla! form builder, flexible and easy to use. As a mature extension, RSForm!'s quality is expressed by the large number of Joomla! sites that are using it - well over 5000, since its release, back in 2007.

RSForm

3.Xpert Contact

Most module ajax based contact for for Joomla. You can create as many field as possible from xml and create different form for different page.

Xpert Contact

4. Proforms

Its advantage is the ease-of-use but also provides an app system to get enhanced. The apps are provided by the developers themselves and are mostly commercial. Unlike BreezingForms, support is limited on domains, keep that in mind if you need it for plenty of installations across different domains.

ProForms

5. Form Maker

Form Maker is a user-friendly form builder with drag and drop interface, which allows easily move form fields for simple management. This will help to align form fields next to one another or arrange them in sections.

Form Maker

There are plenty of other form extensions for Joomla!® available but the collection above are definitely the best ones available at this time.

Add a comment

CHANGE FIRST DAY OF WEEK IN CALENDAR ELEMENT

 CHANGE FIRST DAY OF WEEK IN CALENDAR ELEMENT

 

Here it is explained how to make Monday the first day of week in Calendar element with date format "%Y-%m-%d"

Go to form Advance Options > More Options > Scripts > Initialization Script > Custom > Press "Create Code framework" and paste this in between :

 

Calendar.setup({
        inputField     :    "ff_elem1717", 
        ifFormat       :    "%Y-%m-%d",
        button         :    "ff_elem1717_calendarButton",
        align          :    "Bl",
        singleClick    :    true,
        firstDay: 1
    });

 

The whole code will look like this:

function ff_formName_init()
{
Calendar.setup({
        inputField     :    "ff_elem1717", 
        ifFormat       :    "%Y-%m-%d",
        button         :    "ff_elem1717_calendarButton",
        align          :    "Bl",
        singleClick    :    true,
        firstDay: 1
    });
} // ff_formName_init

 

NOTE: To make this work for your form you have to find your calendar element ID and replace ff_elem1717 with it. Also, you have to replace ff_elem1717_calendarButton with your calendarButton ID. Also, formName will be the name of your form.

The first day of week can be set to what is suitable by changing firstDay: 1 to another value.

Add a comment

LIMIT MAXIMAL NUMBER OF FILES TO UPLOAD

Here it is explained how to limit the number of files to upload when Allow multi HTML5/Flash uploads checkbox is checked.

Please follow these instructions.

Go to Properties of the "File upload" element in your form and in the Validation section check Required checkbox. Then select Custom as the validation type and in the code area paste in the following:

 

function ff_uploadelementname_validation(element, message)

{

var children = jQuery('.bfFlashFileQueueClass').children();

var len = Number(children.length);

console.log(len);

if ( len > 3) {

if (message=='') message = " Too many files uploaded.\n"

ff_validationFocus(element.name);

return message;

} // if

return '';

}

 

NOTE: In the code above replace uploadelementname with the Name of your File upload element.
This is the example where 3 is the maximum number of files to upload. 

In the following line of code, replace 3 with the maximum number wanted.

That will limit the number of files that can be uploaded.

If a user tries to submit the form with too many files uploaded an error message will be shown and won't be able to submit the form until he reduces the number of uploaded files to less or equal to the maximal.

 

Add a comment

Count Number of Records

Crosstec Blog


To count the number of records for a certain form and insert a record count in a field in a form, the best way is to create a custom submit button which has in an Actionscript an Ajax call to the database to get the count. That way, records will be counted when the submit button is pressed.

To do so, please follow these steps:

1) Go to your form's Properties and set "Include submit button" to "No". That will remove regular submit button.

2) At the end of your form create new element of Submit button type. What you write in the "Value" field for that button element is what will be displayed on that button in your form, so that it the place where you should put, for example, "SUBMIT" since this button will use to submit the form.

3) Go to the "Advanced" properties of that newly created submit button element and in the "Actionscript" section set "Type" to "Custom" and mark "Click" as "Action".
In the code are below put the following code:

 

function ff_submit_action(element, action)
{
jQuery.ajax({
type: 'GET',
url: 'http://localhost/value.php',
data: 'test',
success: function(data){
ff_getElementByName("ELEMENTNAME").value = data;

if(typeof bfUseErrorAlerts != 'undefined'){
JQuery(".bfErrorMessage").html('');
JQuery(".bfErrorMessage").css("display","none");
}
error = ff_validation(0);
if (error != '') {

if(typeof bfUseErrorAlerts == 'undefined'){
swal(error);
} else {
bfShowErrors(error);
}
ff_validationFocus();
} else
ff_submitForm();
}
});
} // ff_submit_action

 

NOTE: In the code above you have to replace "submit" with the name of the submit button that you have created.
Furthermore, replace ELEMENTNAME with the name of the name of element in your form which should be filled with count number.
Finally, make sure to replace 'http://localhost/value.php' with the correct path for your site to the "value.php" file.

4) Go to the Joomla root folder and create there file named value.php with the following content:

<?php
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/' )); 
require_once ( JPATH_BASE .'/includes/defines.php' );
require_once ( JPATH_BASE .'/includes/framework.php' );

$db = JFactory::getDBO(); 
$db->setQuery('Select Count(*) From #__facileforms_records Where name="MyFormName"'); 
$result = $db->loadResult()+1;

echo json_encode($result);
?>


NOTE: Make sure to replace MyFormName with the actual name of your form.

That will fill the form field with the record count.

Solution provided by MihaelaK ( thanks ).

Add a comment

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