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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:53:40+00:00 2026-06-01T01:53:40+00:00

Although I have my php validation doing this, thought I may as well pop

  • 0

Although I have my php validation doing this, thought I may as well pop it in to javascript validation too, just to pick it up before I force a page reload.

I want to test if an input has only letters in it. I have had a look around and cant get a concise block of code to use. Any help would be great.

var x = $('firstName').val();
var onlyLetters = /^[a-zA-Z]*$/.test(myString);
if (x != onlyLetters) { display error; } return true;

I’m still new to javascript which is why I cant see why the above code isn’t working. 🙂

Thanks in advance.

  • 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-01T01:53:41+00:00Added an answer on June 1, 2026 at 1:53 am

    .test() returns a boolean true/false result. You then compare this true/false to the original string you tested, which will fail. It should be

    if (!onlyletters) { display error; }
    

    since it’s already a boolean value.

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

Sidebar

Related Questions

I hope this is a relatively easy problem although I have spent hours websearching
I am busy creating my very first Facebook application, and although I have PHP
Although I have instructed php to only log an error once - i see
I'm using this plugin to style my selectboxes. I have a PHP script that
I have something like the following code in one of my views: <?php $this->load->view('_validation_error',
Ok, so I have this PHP script that runs in a nice little infinite
I am running into a blank page, and although I have told PHP to
Although I have experience with SQL and generating HTML reports with PHP, I'm a
Although Rails and PHP have different deployment methods, what is the preferable way to
Although I have research this topic I don't really seem to understand how to

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.