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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:03:51+00:00 2026-06-06T19:03:51+00:00

js validation works perfectly when I step through it, but fails at normal speed.

  • 0

js validation works perfectly when I step through it, but fails at “normal speed.” SPECIFICALLY: if a dup email is caught but the other fields are filled in correctly, the form can be submitted (but no error is forthcoming when stepping through the code). Has anyone seen this before? I know I could just code it a different way, but I cannot simply walk away from this simple problem that’s even become a bottle kneck without first understanding why this isn’t working.

My approach is to validate onblur and onsubmit. I am using the jquery selector only for convenience and then again for an ajax call, but otherwise i’m using js. I am doing a loop through the fields but only operating on text and password fields.
checking for blanks
checking for no numbers in name
checking for email address properly formatted
and then checking for unique email in the email field
annotated code below for js and form below:

//registration validation
$('.validate').blur(function() {
var theForm = document.registerNewUserForm;         
//removes error messages from html before the run
clearAllErrors(theForm);
var msg = "";
var mdiv;
theForm.submit.disabled=true;
document.getElementById("submitButton").disabled = true;

for (var i = 0; i < theForm.elements.length; i++) {

    //mdiv is set to form element being evaluated at the time
    mdiv = document.getElementById(theForm.elements[i].name + "Message");

    msg = validateField(theForm.elements[i]);
    if(msg != "") {
        mdiv.innerHTML = msg;
        break;
    }
}
if(msg == "") {
    theForm.submit.disabled=false;
    document.getElementById("submitButton").disabled = false;
}
});


$('#registerNewUserForm').submit(function() {
var theForm = document.registerNewUserForm;
clearAllErrors(theForm);
var msg = "";
var mdiv;
for (var i = 0; i < theForm.elements.length; i++) {

    //mdiv is set to form element being evaluated at the time
    mdiv = document.getElementById(theForm.elements[i].name + "Message");

    msg = validateField(theForm.elements[i]);
    if(msg != "") {
        break;
    }
}
if (msg != ""){
    mdiv.innerHTML = msg;
    return false;       
}  else {
    theForm.submit();
}   
});

function validateField(theField) {
msg = "";   
//all fields are required
if (theField.type == "text" || theField.type == "password") {
    if (theField.value == "") {
        msg = "The " + theField.name + " field is required.";
    }
}

//name fields are non-numeric
if (theField.name == "fullName"){
    if (hasNumber(theField.value) == true){
        msg= "The Name field is non-numeric.";
    }
}

//email must be correctly formatted
if (theField.name == "email") {
    msg = emailCheck (theField.value);
    if (msg == "") {
        //email address must also be unique
        chkEmail();
        msg = document.getElementById('emailMessage').innerHTML;
    }
}   
return msg;
}

function chkEmail() {
emailAddr = document.getElementById("email").value;
$.ajax({
    url: '/chkEmail',
    type: 'POST',
    data: 'emailAddr=' + encodeURIComponent(emailAddr),
    dataType: "xml",
    context: document.body,
    success: function(data) {
        document.getElementById('emailMessage').innerHTML = $(data).find("message").text();
    }
});
}


<form name="registerNewUserForm" id="registerNewUserForm" action="/register" method="post">
    <br/>
    <div>Create an Account and join the fun!</div>
    <div><input class="validate" type="text" id="fullName" required placeholder="Full Name" name="fullName" value="" size="30"></div>
    <div id="fullNameMessage" class="error"></div>
    <div><input class="validate" type="text" id="email" required placeholder="Email Address" name="email" value="" size="30"></div>
    <div id="emailMessage" class="error"></div>
    <div><input class="validate" type="password" id="passWord" required placeholder="Password" name="passWord" value="" size="30"></div>
    <div id="passWordMessage" class="error"></div>
    <div style="position:relative;left:173px;"><input id="submitButton" type="submit" value="Signup for PastelPlanet"></div>
    <input type="hidden" name="formName" value="registerNewUserForm">
    <input type="hidden" name="urlDestination" value="">
</form>
  • 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-06T19:03:54+00:00Added an answer on June 6, 2026 at 7:03 pm

    Your “chkEmail” function involves a call to the server, and it’s asynchronous. The call to the server will not be complete when the function returns, when you’re running at “full speed”.

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

Sidebar

Related Questions

I have my yii login form ajaxvalidation works perfectly in normal mode, But it
The form validation works fine, so if u leave the email input blank and
I have a slight problem with usage of jquery validation plugin. It works perfectly
I made a certain piece of functionality which works perfectly on Chrome, but not
My myclickHandler function works perfectly but when I go on to my error console
I'm developing a VB.NET 1.1 web application. All validation and RegEx controls work perfectly
I have a form that calls on two separate models. My validation works correctly
I am using the Validation Plugin for jQuery and it works wonders. Except when
I'm using Springs annotations based form validation (mainly @NotBlank and @Length) which works great.
As far as I know the System.ComponentModel.DataAnnotations.DataTypeAttribute not works in model validation in MVC

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.