Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9182059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:28:14+00:00 2026-06-17T18:28:14+00:00

I am using the UF Validator on a project and I’d like to add

  • 0

I am using the UF Validator on a project and I’d like to add some custom validation checks.

I want to add a username check that gives an error if the input contains anything other than a-z 0-9. No spaces or anything. Similarly I want to add a name check that only allows a-z, but does allow spaces.

I am basing my checks on the built in email validation. Here is the filter:

var mail_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

And here is the code for the email check:

// E-MAIL VALIDATION
    if (obj.hasClass('req-email')) {
        tmpresult = mail_filter.test(valAttr);
        if (!tmpresult) errorTxt = (valAttr == '') ? opts.errorMsg.reqMailEmpty : opts.errorMsg.reqMailNotValid;
        result = result && tmpresult;
    }

And here are my filters:

var username_filter = /^[a-zA-Z0-9]/;
var name_filter = /^[a-zA-Z ]/;

And here is my code:

// USERNAME VALIDATION
    if (obj.hasClass('req-username')) {
        tmpresult = username_filter.test(valAttr);
        if (!tmpresult) errorTxt = (valAttr == '') ? opts.errorMsg.reqUsernameEmpty : opts.errorMsg.reqUsernameNotValid;
        result = result && tmpresult;
    }
// NAME VALIDATION
    if (obj.hasClass('req-name')) {
        tmpresult = name_filter.test(valAttr);
        if (!tmpresult) errorTxt = (valAttr == '') ? opts.errorMsg.reqNameEmpty : opts.errorMsg.reqNameNotValid;
        result = result && tmpresult;
    }

I have referenced them here as well:

// gather inputs & check is valid
    $(merged_options.scope+' .req-email, '+merged_options.scope+' .req-string, '+merged_options.scope+' .req-same, '+merged_options.scope+' .req-both, '+merged_options.scope+' .req-numeric, '+merged_options.scope+' .req-date, '+merged_options.scope+' .req-min, '+merged_options.scope+' .req-username, '+merged_options.scope+' .req-name').each(function() {
        thisValid = $.formValidator.validate($(this),merged_options);
        boolValid = boolValid && thisValid.error;
        if (!thisValid.error) errorMsg  = thisValid.message;
    });

The corresponding error messages exist as well but I don’t think they need showing.

I thought this would work fine but when I try, it behaves quite strangely. Showing the wrong error messages and not validating it how I want it to. I’ve checked their website and searched on here but can’t find anything relating to it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:28:15+00:00Added an answer on June 17, 2026 at 6:28 pm

    Your regex only test for the presence of a single character at the start of the string.
    You need to add a + to indicate that you want to match one or more characters, e.g. [a-z\d]+, or you can specify a range.

    For example, the regex below specify that the strings must be between 1 and 20 characters long.

    var username_filter = /^[a-z\d]{1,20}$/i;
    var name_filter = /^[a-z ]{1,20}$/i; 
    

    The end character $ is needed, or you are only specifying what must be at the start of the string.

    The i flag means a case-insensitive match, assuming that is what you want; \d is equivalent to [0-9].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Laravel, I am using custom validation in my project to check whether mininum
I validate in two ways - using spring validator for custom validation and javax.validation
I'm using apache commons validator in few classes in my project, and I want
Hi I have some jquery code that checks to see if an asp validator
I'm using following validator for my project: http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ . I've encountered some difficulties, while
I'm working on a Spring MVC project in which I'm using Hibernate Validator to
I'm using the jquery datepicker plugin at http://plugins.jquery.com/project/datepick with the datepicker validation plugin. <script
I am using [ http://validator.w3.org/][1] for markup validation and I continue to get errors
I'm trying to integrate bean validation using hibernate validator to my web application :
My document is getting some errors when using the W3C validator because some of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.