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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:23:22+00:00 2026-06-04T17:23:22+00:00

I want to parse the input and check whether the entered colored format is

  • 0

I want to parse the input and check whether the entered colored format is in either RGBA or HEX format and also give user space for entering color names of regular colors with a switch case.

I found a regex for hex colors and regular color names but was unable to find one for RGBA.

Javascript

function verifycolor(colorcode) {
  var regColorcode = /^(#)?([0-9a-fA-F]{3})([0-9a-fA-F]{3})?$/;
  if(regColorcode.test(colorcode) == false)
    document.getElementById("status").innerHTML = "Color is not yet valid.";
  else if(regColorcode.test(colorcode) == true)
    document.getElementById("status").innerHTML = "You have entered a valid color code";
}

jsfiddle didn’t work for me with this code. Dunno the reason. So it’s here.

Can anyone help me out to do the same for RGBA colors. It would be great if the regex can parse it into red, green, blue and alpha.

  • 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-04T17:23:24+00:00Added an answer on June 4, 2026 at 5:23 pm

    Some search gave me this RGB color parser:

    • http://www.phpied.com/rgb-color-parser-in-javascript/

    It does exactly what you want (even can output the color channels). And of course it can be used for color verification.

    From the description:

    A JavaScript class that accepts a string and tries to figure out a
    valid color out of it. Some accepted inputs are for example:

    • rgb(0, 23, 255)
    • #336699
    • ffee66
    • fb0
    • red
    • darkblue
    • cadet blue

    DEMO: http://www.phpied.com/files/rgbcolor/rgbcolor.html

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

Sidebar

Related Questions

I want to parse the input string and extract the values from it. My
I want to parse an input file that has syntax similar to c++ source.
When a user is inputting something, I need to check user input against the
I'm want to parse a custom string format that is persisting an object graphs
I'm trying to write a grammar to parse an input of format -- sfasfa
I'm trying to parse a URI from user input. I'm assuming some users won't
I've made a little forum and I want parse the date on newest posts
I want to parse file and delete some header strings on ruby. File(s) to
I want to parse this URL with PHP to get the latitude of a
I want to parse the JSON [ { food: [ { name: pasta, price:

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.