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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:34:24+00:00 2026-05-25T22:34:24+00:00

I am building validation for my forms. I have covered the input text fields

  • 0

I am building validation for my forms. I have covered the input text fields with the folowing code:

function validateForm_id()
{
var ctrl = document.forms["form1"]["id"];
var x=ctrl.value;
if (x==null || x=="") {
document.getElementById('id').style.backgroundColor="#FFD4D4";
document.getElementById("id").style.borderColor="#FF7A7A";
document.all.id.innerText = "password required";

I would like to validate the value from my select drop down boxes. The values are:

— Select Title —
Mr
Mrs
Ms

I would like the user to not be able to submit if — Title — is the value from the box.

how do i refer to the first value of the dropdownbox in the if (x==null || x=="") of the above code? Here is my dropdown:

<select name="title" onKeydown="Javascript: if (event.keyCode==13) post();" onFocus="validation_title()" onBlur="return validateForm_title()" id="title">
    <option>- Title -</option>
    <option value="1">Mr</option>
    <option value="2">Mrs</option>
    <option value="3">Ms</option>
    <option value="4">Other</option>
</select> <div align="center" id="title" style="font-size:small; color:#FF0000;"><script type="text/javascript">document.all.title.innerText = " ";</script></div>
  • 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-25T22:34:25+00:00Added an answer on May 25, 2026 at 10:34 pm

    You can use the selectedIndex property of <select> to check out that the first index is never selected.

    if (ctrl.selectedIndex == 0) { alert('The Title field is required'); }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that contains messages for form field validation. However I would
I am building a form, where required field validation must have been checked. I
I'm building an application which basically has a lot of user input, text boxes,
I m building a very simple form validation which validates only required fields. This
I'm building form validation controls for our C# ASP application. The bulk of the
I'm building an ASP.NET MVC application with a form that needs validation. The majority
I'm building up a library of filters for a validation class in PHP, some
I am building a PHP registration form which takes the following fields for up
I have a simple form on an ASP.NET MVC site that I'm building. This
I'm building a form class in python for producing and validating HTML forms. Each

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.