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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:10:26+00:00 2026-05-23T05:10:26+00:00

The custom function formdvalidate should run after else but it doesn’t. How can I

  • 0

The custom function formdvalidate should run after else but it doesn’t. How can I trigger it to run?
What I like to accomplish here is to check the text-fields of a form. If there are less then 3 characters its show the user some text. If the input is more then 3 it submits the form.

–I was thinking to wrong way, this works better.

$('#submit').click(formdvalidate);

The function

function formdvalidate(){
    $(".form-sel").each(function(){
        var n = $(this).closest('.contain-form').find('.custom:first').val().length;
        if ($('option:selected', this).val() === 'custom' && n < 3) {
            $(this).closest('.contain-form').find('.alert-short:first').show();
        }else{                          
            $('#poll').submit();
        }
    });                 
}
  • 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-23T05:10:27+00:00Added an answer on May 23, 2026 at 5:10 am
    1. A function assigned as a click handler via .click() takes a jQuery event object as its first param–you named that param the same as your function
    2. formdvalidate === true will never evaluate to true as formdvalidate is a function in the global scope, and a jQuery event object in the click() scope as per item 1
    3. In your formdvalidate function, your return is inside of the .each() function, so formdvalidate never actually returns anything.

    I’m not sure what you’re really after or what your page looks like, but based on your comment to Slava Yanson, my best guess for you is below (although there are still things I am unsure of…)

    $( '#submit' ).click( function( e )
    {
      if( formdvalidate() === true) 
      {
        $( '#poll' ).submit();
      }
    
      e.preventDefault();
    } );
    
    function formdvalidate()
    {
      var returnValue;
    
      $( '.form-sel' ).each( function()
      {
        var $containForm = $( this ).closest( '.contain-form' ),
            $alertShortFirst = $containForm.find( '.alert-short:first' ),
            n = $containForm.find( '.custom:first' ).val().length;
        if( $( 'option:selected', this ).val() === 'custom' && n < 3 )
        {
          $alertShortFirst.show();
          returnValue = false;
        }
        else
        {
          $alertShortFirst.hide();
          returnValue = true;
        }
      } );
    
      return returnValue;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To clarify, how can run a custom function right before jquery's validation plugin runs
i'd like to know how i can make my custom function in tinymce. assumed
How can i get the string within a parenthesis with a custom function? e.x.
i use to create a custom function like winexec(...):Hwnd that will retun the handle
I'd like to call a custom function that is defined in a Python module
In a simple aspx page I can have a custom JavaScript function postback as
Is there any way I can add a custom function to WSS 3.0 that
how can i add a custom function to a string type example: string test
MSDN You can define a custom function in the storage model by adding a
how can i add a custom function / object to the standard array of

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.