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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:20:02+00:00 2026-06-05T07:20:02+00:00

function validateForm() { var ddlTitle = document.getElementById(‘<%=ddlTitle.ClientID %>’); if (ddlTitle.value.replace(/^\s+|\s+$/, ”).length < 1) {

  • 0
    function validateForm()
    {
       var ddlTitle = document.getElementById('<%=ddlTitle.ClientID %>');
        if (ddlTitle.value.replace(/^\s+|\s+$/, '').length < 1)
                    {
                        alert("Title should not be blank.");
                        ddlTitle.focus();//not working in mozilla but fine in IE and chrome
                        return false;
                    }

    }
<asp:DropDownList ID="ddlTitle" runat="server" CssClass="csstextbox">
                    <asp:ListItem Value="">[Select]</asp:ListItem>
                    <asp:ListItem>Dr.</asp:ListItem>
                    <asp:ListItem>Dr.(Mrs.)</asp:ListItem>
                </asp:DropDownList>
    <asp:Button ID="btn" runat="server" CssClass="cssbutton" Text="Save" Width="60px"
                        OnClientClick="return validateForm();"  />

This is HTML source

ddlTitle = document.getElementById('contentPlaceHolderMain_ddlTitle');
function validateForm()
        {
            if (ddlTitle.value.replace(/^\s+|\s+$/, '').length < 1)
            {
                alert("Title should not be blank.");
                ddlTitle.focus();
                return false;
            }
         }

Problem is only for dropdownlist works well for Textbox

  • 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-05T07:20:03+00:00Added an answer on June 5, 2026 at 7:20 am

    Focus() must be setting focus try using your keyboard key Up/ down arrow and check.

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

Sidebar

Related Questions

The javascript: function validateForm() { var x=document.forms[newsletter][agree].value; if (newsletter.agree.checked != 1) { alert(Checkbox must
function something(frm,i){ //var ch=frm.outof1.value; for(var j=1;j<=i;j++) { //var b=outof + j; alert(frm.outof+j.value); } //alert(outof
I have this validate form function: function ValidateForm() { var chks = document.register.elements['sendto[]']; var
I have a pretty straight-forward javascript form validation script written: function validateForm(){ var x=document.forms[contactForm][firstname].value;
Hello I get a weird error in this code: function validateForm(aform) { var s=;
function parseAttach(b) { var h=; for(i=0;i<b.length;i++) { var a=b[i]; switch(a['type']) { case image: h+='<li
I have some code for validating date below: function validateForm() { var errFound =
function test() { alert(Array.join.call(arguments,'/')) //alerts / alert(Array.prototype.join.call(arguments,'/')) //alerts Js/JScript alert(Array.join(arguments,'/')) //alerts Js/JScript } test('Js','JScript');
How do i introduce validation before remote_form_for submits? I have javascript function called validateForm()
I need help with javascript. here is my problem: <script type=text/javascript> function validateForm() {

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.