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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:40:59+00:00 2026-06-17T22:40:59+00:00

Hello! I am coding a new HTML form that will collect upon many more

  • 0

Hello!

I am coding a new HTML form that will collect upon many more items a state abbreviation (i.e. “ks”). Right now I have the -input field- limited so it only allows 2 characters. That doesn’t keep visitors from entering something random into the field like “SS”.

I am wanting a code that allows me to limit what can be placed in that field to only USA’s official state abbreviations.

I am using HTML, CSS, and Javascript so far in my website. Thank you for all your help and ideas!!

  • 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-17T22:41:00+00:00Added an answer on June 17, 2026 at 10:41 pm

    Update. Added all states, uppercase handling and jsfiddle link.

    Here is a pure javascript implementation, should give you an idea of what you need to do:

    <script>
        function validateState(el) {
        //put all states in this array. 
        var states =    ["AK","AL","AR","AS","AZ","CA","CO","CT","DC","DE",
    "FL","GA","GU","HI","IA",
    "ID","IL","IN","KS","KY","LA","MA","MD","ME","MH","MI","MN","MO","MS","MT",
    "NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","PR","PW","RI",
    "SC","SD","TN","TX","UT","VA","VI","VT","WA","WI","WV","WY"];
        for(var i=0;i< states.length;i++) {
          if(el.value.toUpperCase() == states[i]) {
            return true;
          }
        }
        //clear element if it doesn't match a state
        el.value = ""; //you could maybe do something else here.
        return false;
    }
    </script>
    <input class="up" type="text" maxlength="2" onchange="validateState(this);"/>
    

    See it working live here : http://jsfiddle.net/k7QQs/

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

Sidebar

Related Questions

new to Laravel (coming from Java spring), while using Route::get('/', function() { return Hello
Hello im coding a plugin for the game minecraft using Bukkit. Basically when a
Hello all I am working on html and javascript.And I am going to ask
Let's say I have the following HTML code <div id="outer"> <div id="inner">Hello World</div> </div>
I decided that I was ready to try something new, after a few years
This is painful. I copied and pasted the follow text to a new html
I'm new to coding and hope someone could help me with my hopeless code
I'm pretty new to J2ME development scene. And for that matter, have just recently
First off my background: I'm new to Java coming over from Ruby. If that
I was just practicing some coding and noticed that I was able to use

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.