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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:38:45+00:00 2026-05-21T17:38:45+00:00

How do I ensure that there are no special characters in the name except

  • 0

How do I ensure that there are no special characters in the name except an apostrophe…Eg:- I can allow O’Connor but not John “Doe” ? Please help.

  • 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-05-21T17:38:46+00:00Added an answer on May 21, 2026 at 5:38 pm

    Here’s a working example of how you’d use a regular expression to check for a valid name given the conditions you laid out:

    <!DOCTYPE html>
    <html>
    <head>
        <title>Check for a good name</title>
        <script>
        var goodName = /^[A-Za-z'\s]+$/;
    
        function checkName(name){
            if (goodName.test(name)) {
                alert("Name is great!");
            } else {
                alert("Name contains illegal characters");
            }
        }      
        </script>
    </head>
    <body>
        <form onsubmit="return false;">
            <input type="text" name="name" size="20">
            <input type="button" value="Check" 
                                 onclick="checkName(this.form.name.value);">
        </form>
    </body>
    </html>
    

    The /^[A-Za-z'\s]+$/ regular expression allows uppercase English, lowercase English, apostrophes, and spaces. (It’s similar to the one proposed by Afiefh, with the addition of the \s to allow spaces, and the + instead of the * to prevent blank names from passing the test.)

    As David Dorward suggests above, if you really are using this to test names, you might consider relaxing the rule to accommodate international names by changing line 6 to this:

    var goodName = /^([ \u00c0-\u01ffa-zA-Z'\-])+$/;
    

    This allows unicode characters, apostrophes, and hyphens.

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

Sidebar

Related Questions

In most modern IDEs there is a parameter that you can set to ensure
I need to ensure that the user login form for Drupal can not be
I want to ensure that there are no duplicate book titles in the following
Is there any way to ensure that a class posts a particular NSNotification? (I
Is there a mechanism to ensure that the tests to ensure that the data
In the 1.6 API, is there a way to ensure that the onStart() method
How can I ensure that information isn't returned from a webmethod or mvc action
How can I ensure that all data that I've erase from the db tables,
I've several records in a table. And if I want to ensure that there
How do I ensure that there are no unexpected functions inherited from the parent

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.