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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:05:02+00:00 2026-05-27T12:05:02+00:00

I have coded custom form validation. validation is working fine all browser but when

  • 0

I have coded custom form validation. validation is working fine all browser but when I am pressing enter key IE is not submitting from if user entered correct data… on click of button its submitting form. I have tried to debug it , its returning true after validation but not submiting form…

(function($){
$.fn.securityFramework = function() {
    var form = $(this);
    var $submitBtn = $('input.sf-submit');

    var errorClass = "error";
    var passClass = "pass";
    var MandatoryClass = "mandatory";
    //var $securityQuestions = $('.securityQuestions');

    // used in form submission
    var submitOK = false;
    var currentPWResult = true;
    var tcResult = true;

    //check username length
    var $userName = $('#userName',form);

    // create empty warning spans to stop focus issues in IE
    //displayResult($('input[type=text]', form), "","");
    //displayResult($('input[type=password]', form), "","");

    /* Registration form checks */
    // check user name for length and invaid characters
    $userName.keyup(function() {
        var userResult = minLength(6, $userName.val().length);
        var userNameResult =  validUserName($userName.val());
        if ( $(this).val() != "" ) {

            if ( userResult || userNameResult ) {
                if(userResult) {
                    //displayResult($(this), 'Please choose a longer username', errorClass);
                    $(this).focus();
                } 

                if(userNameResult) {
                    //displayResult($(this), 'Your username contains invalid characters', errorClass);
                    $(this).focus();
                }
            } else {
                //displayResult($(this), '', passClass);
                $(this).focus();
            }
        }
    });


    // check that all form text inputs are not empty
    $('input[type=text]:not(input.email)', this).blur(function() {
        $(this).each(function(index, value) {
            if( isEmptyString($(this)) ) {
                var message = checkManitoryMessage($(this));
                //displayResult($(this), message, MandatoryClass);
            } else {
                // remove mandatory class
                if ( $(this).siblings().hasClass('mandatory') ) {
                    $(this).siblings().remove();
                }
            }
        });
    });

    $('input[type=password]:not(input.password)', this).blur(function() {
        $(this).each(function(index, value) {
            if( isEmptyString($(this)) ) {
                var message = checkManitoryMessage($(this));
                //displayResult($(this), message, MandatoryClass);
            } else {
                // remove mandatory class
                if ( $(this).siblings().hasClass('mandatory') ) {
                    $(this).siblings().remove();
                }
            }
        });
    });


    // check validation on form submission
    form.submit(function(e) {
        // trigger checks for empty fields
        $('input[type=password]', form).trigger('blur');
        $('input[type=text]', form).trigger('blur');

        submitCheck();
        if(submitOK ) {
            alert("true");
            return true;
        } else {
            return false;
        }
    }); 


    // generic testing functions
    function emailVal(emailAddress) {
        emailAddress = emailAddress.toLowerCase();
        var pattern = new RegExp(/^[a-z0-9_\+-]+(\.[a-z0-9_\+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,4})$/);
        return pattern.test(emailAddress);
    }

    // check for empty string
    function isEmptyString(jQueryObj) {
        return ( jQueryObj.val() == "");
    }

    // check username for invalid characters ("!£$%?/@)
    function validUserName(name) {
        var pattern = new RegExp(/["\u00A3!\$%\?/@]/);
        return pattern.test(name);
    }

    // check string length against a value
    function minLength(minLength, string) {
        return((string+1) <= minLength);

    }

    // check that two strings match
    function checkStringsMatch(string1, string2){
        // console.log('str1: ' + string1 + ' str2: ' + string2);
        return(string1 == string2);
    }
    // check for password validation
    function checkPasswordValidation(passwordObj){
        password=passwordObj.val();
        var pattern = new RegExp(/^.*(?=.{8,})(?=.*[a-zA-Z])(?=.*\d).*$/);
        return pattern.test(password);
    }

    // check password strength
    function checkPwStrength() {
        var pwStrength = $('#strengthWidget').attr('class');
        // check class for password classification
        if(pwStrength == 'pw-weak') {
            return true;
        }
        return false;
    }

    // generic display error and confirm message function
    function displayResult(selector, message, className) {
        // check to see if input has a wrapper span to hold message
        if(selector.parent().hasClass('wrapper')) {
            // has wrapper, remove message contained
            selector.parent().children('span').remove();
        } else {
            // no wrapper, add one to append message to
            selector.wrap('<span class="wrapper"></span>');
        }
        selector.parent().append('<span class="' + className + '">' + message + '</span>');
    }

    // checks to see if any errors on page, if none found enable submission
    function submitCheck() {
        var $errorsExist = $('.error', form);
        var $mandErrorsExist = $('.mandatory', form);
        var $highlightErrorsExist = $('.highlightError', form);
        // console.log($highlightErrorsExist.length);
        // console.log('$errorsExist.length: ' + $errorsExist.length);
        // console.log('$mandErrorsExist.length: ' + $mandErrorsExist.length);

        if ($errorsExist.length || $mandErrorsExist.length || $highlightErrorsExist.length ) {
            submitOK = false;
        } else {
            submitOK = true;
        }
        // console.log('submitOK = ' + submitOK );
    }

    function checkManitoryMessage($object) {
        var inputId = '';
        inputId = $object.attr('id');

        inputId = inputId.toLowerCase();
        if (inputId == undefined) {
            inputId = 'Manditory Field';
        } else {
            inputId = sfErrors[inputId];
        }
        return inputId;
    }

    return form;
}; // end of plugin
})(jQuery);
  • 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-27T12:05:03+00:00Added an answer on May 27, 2026 at 12:05 pm

    You can try:

    $("form input").keypress(function (e) {
       if(e.which === 13) {
          $("form").submit();
       }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators? For
I have a form with some custom validation. There is a button on the
I have custom coded several enterprise applications for mid to large organizations to use
Within my web application I am using some custom validation for my form fields.
I have created custom registration form in drupal 6. i have used changed the
What I'm looking for: way to have innate html 5 form validation using the
So I have this jQuery Validation plugin, and it has a custom success message.
I am writing a custom validation set that will display all missing elements on
Hi I am working on a custom form field validator, it seems like the
I have some problems getting the custom formated JSON data into a dijit.form.FilteringSelect. It

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.