TOPIC:

Textfield element validation 1 month 2 days ago #244688

  • Topic Author
  • gtgt
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 56
  • Thanks: 1
Dear Crosstec,

Is it possible to create a special format validation script?

I have a texfiled element which should be like this:
12345678-1-23

8 numeric characters & "-" & 1 numberic character & "-" & 2 numeric characters

I found a pattern validation code in hte examles and try to rewrite. But something is wrong it is not working

Thanks in advance.


My code is:

function ff_specialstring(element, message)
{
var pattern = /^d{8}\-d\-\d{2}$/
if (!ex.test(element.value)) {
if (message=='') message = element.name+" invalid format.\n";
ff_validationFocus(element.name);
return message;
} // if
return '';
} // ff_specialstring

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

Textfield element validation 1 month 2 days ago #244689

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

Please try this:
function ff_specialstring_validation(element, message)
{
   var ex=/^[0-9]{8}(?:-[0-9]{1})?(?:-[0-9]{2})?$/;
    if (ex.test(element.value)) return '';
        if (message=='') message = element.name+" faild in my test.\n";
        ff_validationFocus(element.name);
        return message;
} // ff_specialstring_validation

Let me know if it works for you.

Regards,
Tihana

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

Last edit: Post by tihana.krivic.

Textfield element validation 2 weeks 2 days ago #245874

  • Topic Author
  • gtgt
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 56
  • Thanks: 1
Dear Tihana,

It works 50%

For example 12345678-9-1 is not accepted, which is OK.
But 12345678 is also accepted by the validation, which should not bo OK.

Can we combine somehow that lenght must be 13 characters?

thx

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

Textfield element validation 2 weeks 2 days ago #245876

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

your number format should be like this (123456789-9-1 and 123456789-1-23)?
I will create example for you.
Just tell me all what you want.

Regards,
Tihana

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

Last edit: Post by tihana.krivic.

Textfield element validation 2 weeks 2 days ago #245877

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

try this:
function ff_nameofelement_validation(element, message)
{
    var ex= /[0-9]{8}[-][0-9]{1}[-][0-9]{2}/;
    var ex1=/[0-9]{8}[-][0-9]{1}[-][0-9]{1}/;
    if (ex.test(element.value) || ex1.test(element.value)) return '';
        if (message=='') message = element.name+" faild in my test.\n";
        ff_validationFocus(element.name);
        return message;
} // ff_nameofelement_validation

Please replace name of element with name of your element in which you want this validation.
This validation is for number like:
12345678-4-1 or 12345678-2-23
NOT for number 12345678 (if the number is like this, a message will be displayed)

Let me know if you need anything else.

Regards,
Tihana

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

Textfield element validation 2 weeks 2 days ago #245879

  • Topic Author
  • gtgt
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 56
  • Thanks: 1
Dear Tihana,

This code is ok. I removed EX1 because only Only 12345678-9-10 type is ok for me.

Must contains 8 digits & "-" & 1 digit & "-" & 2 digits, in this order.

Thanks for your help.

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

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

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

Summer Sale!

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!