TOPIC:

Problem field not required VS script validate !? 2 weeks 2 days ago #275080

  • Topic Author
  • midimoinsdix
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 95
  • 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 !? 2 weeks 2 days ago #275081

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 10535
  • Karma: 3
  • Thanks: 705
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 !? 2 weeks 2 days ago #275082

  • Topic Author
  • midimoinsdix
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 95
  • 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 !? 2 weeks 2 days ago #275084

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 10535
  • Karma: 3
  • Thanks: 705
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 !? 2 weeks 2 days ago #275085

  • Topic Author
  • midimoinsdix
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 95
  • 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 !? 2 weeks 2 days ago #275086

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 10535
  • Karma: 3
  • Thanks: 705
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.103 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

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

Special Offer

Summer 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!