1. Important notice about Cloudbleed - if your site uses the Cloudflare CDN, and you intend to follow the Joomla security team's advice to change your site "secret", you MUST READ THIS NOTICE.
  2. Fabrik 3.6 Released Remember to backup and test your backup before proceeding with this update. Please report any problems you might experience with this new version here on the forum. You are safe to upgrade to Joomla! 3.7 and PHP 7.x with this version of Fabrik. View the blog for more details on this release.

validation is empty or is unique value

Discussion in 'Community Support' started by ErnstJan, Jan 24, 2012.

  1. ErnstJan

    ErnstJan Member

    Level: Community
    Hello,

    In a form I have a field element in which they have to put a number, example 213456789, or if they don't have a number, this field stays empty. This number is a unique value. Is it possible to have combined these two validations (is unique value or is empty). If possible how to achieve this?
    Just let me know.

    Kind regards, Ernst
     
  2. troester

    troester Well-Known Member Staff Member

    Level: Standard
    In the isunique validation set the condition:
    return '{your-table___element}'!='';
    So it's only validating if the element is not empty.
     
  3. ErnstJan

    ErnstJan Member

    Level: Community
    validating is unique value or is empty

    Thanks Troester,

    Works perfect! Last question: is it possible to say this unique value only has nine numbers example: 012345678 or 993456782 (without any other character like , :?# etc) ?
    Just let me know.

    Kind regards, Ernst
     
  4. troester

    troester Well-Known Member Staff Member

    Level: Standard
    You can add a regular expression validation (there have been some threads about validating telephon numbers).
     
  5. ErnstJan

    ErnstJan Member

    Level: Community
    validating is unique value or is empty and regular expression

    Hello Troester,

    Thanks for very quick reply! I found this regular expression and changed it a little:
    /^[0-9]{9}$/ I also added condition if field is left empty. Everything works fine now!
    I appreciate your help very much!


    Kind regards, Ernst
     

Share This Page