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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:26:28+00:00 2026-06-05T02:26:28+00:00

I have a pretty good OOP JS structure in place, but am looking for

  • 0

I have a pretty good OOP JS structure in place, but am looking for some help with validating a username and email field. I have it pretty much working but I think the username and email could be validated better.

I have setup a delegate on a group of fields(elements) and then I perform validation on these. My code validation for username and email fields looks like:

} else if( regExpTest === "AjaxCall") {

if(currentValue.length > 0){

    availability = ZEN.checkAvailability( $this ); //Check weather form input value is available in DB

    availability.success(function (data) {

        if(data == "1" && currentField == 'username'){

            $('#usernameErrorExists').fadeIn();
        }

        if(data == "0" && currentField == 'username'){

            $('#usernameErrorExists').fadeOut();

        }

        if(data == "1" && currentField == 'email'){

            $('#emailErrorExists').fadeIn();

        }

        if(data == "0" && currentField == 'email'){

            $('#emailErrorExists').fadeOut();

        }

    });

    isValid = true;

}

}

The ZEN.checkAvailability function looks like:

ZEN.checkAvailability = function( input ) {

// get input name
var inputName = input.attr('name')

// get value
var inputValue = input.val();

return $.ajax({
    type: "POST",
    url: "/"+ inputName +"-check",
    data: inputName +'='+ inputValue,
    cache: false
});

};

My question is, is there a better way to validate the returned response from the AJAX request?

Thanks
Robert

  • 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-05T02:26:31+00:00Added an answer on June 5, 2026 at 2:26 am

    Got this working better by altering the jQuery fades to a more appropriate time on the error messages.

    Thanks to Chao for their comments.

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

Sidebar

Related Questions

i am pretty good in android but have not developed any games yet, and
I have built a PHP calendar system and have pretty much everything done but
I have a pretty good non-OOP background. I've done lots of Visual Basic coding,
I have a pretty good understanding of MVC 3 model, but are not as
I'm pretty new to OOP (and also in PHP programming), and I have some
I am relatively new to Android development but I do have a pretty good
I have pretty good skills in PHP , Mysql and Javascript for a junior
I have a pretty good idea how to implement fulltext search with MySQL. I
I have a pretty good handle on using models to make database calls and
I think i have a pretty good idea about the volatile keyword in java,

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.