TOPIC:

Problem field not required VS script validate !? 11 months 3 weeks ago #275080

  • Topic Author
  • midimoinsdix
  • Offline
  • Senior Member
  • Senior Member
  • Registered
  • Posts: 100
  • Thanks: 0
Hi,
I have non-required fields (mail, web address) with a validation script (if not empty).
But if they are not filled in (because not required) they remain active and require you to fill in the fields correctly !

how to make the validation script only work if the field is submitted
Thank's for your tips.

Please Log in or Create an account to join the conversation.

Problem field not required VS script validate !? 11 months 3 weeks ago #275081

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Registered
  • Posts: 12079
  • Thanks: 786
Hi,

I think this is not possible, validation field means that on submit if validation is not ok, then error message is there

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Problem field not required VS script validate !? 11 months 3 weeks ago #275082

  • Topic Author
  • midimoinsdix
  • Offline
  • Senior Member
  • Senior Member
  • Registered
  • Posts: 100
  • Thanks: 0
Just to understand,
we can't use a validation formating script on a field that isn't required ?

Please Log in or Create an account to join the conversation.

Problem field not required VS script validate !? 11 months 3 weeks ago #275084

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Registered
  • Posts: 12079
  • Thanks: 786
Hi,

we can modify script with some javascript code, enable empty field for example.

I hope you understand what I am talking about

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Problem field not required VS script validate !? 11 months 3 weeks ago #275085

  • Topic Author
  • midimoinsdix
  • Offline
  • Senior Member
  • Senior Member
  • Registered
  • Posts: 100
  • Thanks: 0
Yes I think that is a good idea :-)

Something like that ?

function ff_valuenotemptyMailValid(element, message)
{
if (element.value!='') ff_validemail(element, message);
if (message=='') message = "Please enter "+element.name+".\n";
ff_validationFocus(element.name);
return message;
} // ff_valuenotemptyMailValid

Please Log in or Create an account to join the conversation.

Problem field not required VS script validate !? 11 months 3 weeks ago #275086

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Registered
  • Posts: 12079
  • Thanks: 786
Hi,

again, on submit if field is empty with this code you will see error message, and it means that field is required.
As I understand you want to enable empty field (not required field)

E.g. for email element field, please go to this element->Propertis->Validation->check Custom and put:
function ff_nameofelement_validation(element, message)
{
var check =
    /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
     if(check.test(element.value) || element.value=='' )
     {
          return '';
     }
     return 'Please enter a valid email';
} // ff_nameofelement_validation
With this code email will be checked, but it is not required field

Please replace nameofelement with name of element for email (not title)

If you need more help, let me know

Regards,
Tihana
The following user(s) said Thank You: midimoinsdix

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Moderators: ForumSupport
Time to create page: 0.059 seconds

Support Chat

Join our Discord chat and enter the Crosstec channels for live-support, chat forums and interact directly with the community!

After joining, please enter the Crosstec Area and use the #crosstec-support or #crosstec-general channels.

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Subscribe to news and updates!

Special Offer

Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

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 and enter the Crosstec channels to receive live support and talk directly to the team!