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

  • Home
  • SEARCH
  • 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

Is there a way to specify a Model in Django such that is ensures
How do you ensure that the project will be build with good design decisions
I need to ensure that any number of websites and services haven't bitten the
How do you properly ensure that a user isnt tampering with querystring values or
How would you ensure that only one user is logged in per account at
I would like to ensure that I only subscribe once in a particular class
How do you ensure that your applications in production are up and running? How
I am trying to ensure that the text in my control derived from TextBox
How could I ensure that all the clients will always be using the latest
We're using TFS Build Server to ensure that all files checked in by developers

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.