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 9321147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:47:47+00:00 2026-06-19T03:47:47+00:00

I am trying (and failing) to write a regular expression statement that checks for

  • 0

I am trying (and failing) to write a regular expression statement that checks for special characters such as !@#$%^&*()_+<>?'”{}[] in my Javascript form validation.

I understand that this has probably been asked 1000 times but i’m under some serious time pressure. If you would rather not answer the question below and you are able to point me in the direction of a previous answer to the above question I would greatly appreciate it.

On a similar note, can anyone tell me why the following is shooting an error when I enter lowercase ‘abc’, etc? I’m baffled.

jQuery.validator.addMethod("specialChars", function( value, element ) {
        var regex = new RegExp("^[a-zA-Z0-9]+$");
        var key = String.fromCharCode(event.charCode ? event.which : event.charCode);

        if (!regex.test(key)) {
           event.preventDefault();
           return false;
        }
    }, "please use only alphanumeric or alphabetic characters");
  • 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-19T03:47:48+00:00Added an answer on June 19, 2026 at 3:47 am

    Instead of writing your own custom method from scratch, include the additional-methods.js file and use the alphanumeric rule.

    $(document).ready(function () {
    
        $('#myform').validate({
            rules: {
                field: {
                    alphanumeric: true
                }
            }
        });
    
    });
    

    Demo: http://jsfiddle.net/YsAKx/


    If you don’t want to include an additional external file, simply copy the default alphanumeric method out of it…

    jQuery.validator.addMethod("alphanumeric", function(value, element) {
        return this.optional(element) || /^\w+$/i.test(value);
    }, "Letters, numbers, and underscores only please");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying (and failing) to write a simple template file: <#@ template language=C# hostspecific=True
I am trying and failing to add datepicker to inputs that are created dynamically.
Imagine we have a program trying to write to a particular file, but failing.
I'm trying to write out to the response stream - but it is failing,
I'm trying to write a tristate switch. But I'm failing to access the default
I am trying to write some Scala code that needs to do something like:
I'm trying to write some code that sets a property on a struct (important
I am trying to write an Http proxy that basically works like indianwebproxy So
I am trying to write a query that looks through all combo_items and only
Im trying to get some simple javascript working in gwt but keep failing. The

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.