SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript is not sending drop down list selected info if valid

    Hi
    I create this JavaScript method to validate drop down box in asp.net form from sending information to DB but when all my entry is valid it will not send it to DB can any one help me to fix it
    Code:
        $("input[id$=btn_createProject]").click(function (e) {
            e.preventDefault();
            var statusVal = $("#MainContent_ddl_status option:selected").val();
            var priorityVal = $("#MainContent_ddl_priority option:selected").val();
            var techVal = $("#MainContent_ddl_defaultTech option:selected").val();
    
            if (statusVal === "-1") {
                $('#msg_validate_status').removeClass("hidden ").addClass("Validator");
                e.preventDefault();
            }
            
            if (priorityVal === "-1") {
                $('#msg_validate_priority').removeClass("hidden ").addClass("Validator");
                e.preventDefault();
            }
    
            
            if (techVal === "-1") {
                $('#msg_validate_tech').removeClass("hidden ").addClass("Validator");
                e.preventDefault();
            }
            
        })

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,810
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    If I followed you correctly, I think you need to remove the first e.preventDefault(); which is at the beginning of your script.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •