TOPIC:

Breezingform custom validation script caused undefined error message 4 weeks 1 day ago #259182

  • Topic Author
  • dnyjordan
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 3
  • Thanks: 0
Hi guys

I just created a validation script for my input field. The problem I am facing is, that a undefined error message shows up if the field is not even filled out, this although its not an obligatory / required field. If you fill it out, the correct error message shows up.

So I would need to know how I could make the undefined error message show up if its left blank or if correct input has been put in, since that is also a case where it still shows up.

This is the code I am currently using:
function ff_Nachricht_validation(element, message)
{
var nachricht_value = ff_getElementByName('Nachricht').value;
if ( nachricht_value !== "") {
var regex = /^([a-zA-Z\s])+$/;

if(!regex.test(nachricht_value)){

return message;
} // ff_Nachricht_validation
}
}


I appreciate any help and thank you all in advance.
Attachments:

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

Last edit: Post by dnyjordan.

Breezingform custom validation script caused undefined error message 4 weeks 1 day ago #259183

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 6086
  • Karma: 3
  • Thanks: 429
Hi,

like this:
function ff_Nachricht_validation(element, message)
{
    var regex=/^([a-zA-Z\s])+$/;
    if (!regex.test(element.value) || element.value == '') {
        if (message=='') message = element.name+" faild in my test.\n"
        ff_validationFocus(element.name);
        return message;
    } // if
    return '';
} // ff_Nachricht_validation

Regards,
Tihana

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

Last edit: Post by tihana.krivic.

Breezingform custom validation script caused undefined error message 4 weeks 1 day ago #259184

  • Mirec's Avatar
  • Mirec
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 206
  • Karma: 2
  • Thanks: 3
Try like this :
{
    var urlRegex = /^([a-zA-Z\s])+$/;
    if ( !urlRegex.test(element.value) ) {
        if (message=='') message = element.name+" faild in my test.\n"
        ff_validationFocus(element.name);
        return message;
    } // if
    return '';
} // ff_avoidLinks


If you get stuck let me know and I will help you!
regards!
Mirko

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

Last edit: Post by tihana.krivic.

Breezingform custom validation script caused undefined error message 4 weeks 1 day ago #259187

  • Topic Author
  • dnyjordan
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 3
  • Thanks: 0
Hi

Thanks for your answer, but unfortunately it still caused the same problem to be present when tested. Same with the solution that tihana.krivic has suggested, there the submit button didnt work anymore.

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

Breezingform custom validation script caused undefined error message 4 weeks 1 day ago #259191

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 6086
  • Karma: 3
  • Thanks: 429
Hi,

like this:
function ff_Nachricht_validation(element, message)
{
    var regex=/^([a-zA-Z\s])+$/;
    if (!regex.test(element.value) || element.value == '') {
        if (message=='') message = element.name+" faild in my test.\n"
        ff_validationFocus(element.name);
        return message;
    } // if
    return '';
} // ff_Nachricht_validation
instead of regex.text I added regex.test. Sorry for my fault

Regards,
Tihana

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

Breezingform custom validation script caused undefined error message 4 weeks 1 day ago #259201

  • Topic Author
  • dnyjordan
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 3
  • Thanks: 0
This worked, thanks. But now the message always shows up even if the field is left empty, and this should not be the case. It really should only show up if the input, if there has been some, is invalid, that the error message shows up. Not when its left empty, as its not a required field. Thats why I had the if (fieldname !== "") in my code.

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

  • Page:
  • 1
  • 2
Moderators: ForumSupport
Time to create page: 0.052 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!