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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:39:00+00:00 2026-06-15T23:39:00+00:00

I have a little problem that I don’t know how to solve. Ajax validation

  • 0

I have a little problem that I don’t know how to solve. Ajax validation works perfect via zend.
Pressing the submit button does validate, but when I got the right email and password it won’t go to the user page. It just remains on that form.
I know it has to do with the return false and true on the submit via Ajax.

Can someone help me to solve that please. I have no idea how to return true on the submit if it detect no errors on validation.

here’s my code:
Ajax and Javascript

$(function() {
    $('input').blur(function() {
        var formElementId = $(this).get(0).id;
        doValidation(formElementId);
    });
});

**$(function() {
    $('#btn_login').click(function() {
        var email = document.getElementById('email').id;
        var password = document.getElementById('password').id;
        doValidation(email);
        doValidation(password);
        return false;
    });
});**

function doValidation(id) {
    var url = '/users/validationform';
    var data = {};
    $('input').each(function() {
        data[$(this).attr('name')] = $(this).val();
    });
    $.post(url,data,function(resp) {
        $("#" + id).parent().find('.errors').remove();
        $("#" + id).parent().append(getErrorHtml(resp[id], id));
    }, 'json');
}

function getErrorHtml(formErrors, id) {
    var o = '<div id="login-error" style="color:red"><ul id="errors-'+id+'" class="errors" style="list-style-type:none;">';
    for(errorKey in formErrors) {
        o += '<li>- ' + formErrors[errorKey] + '</li>';
    }
    o += '</ul></div>';
    return o;
}

Zend controller:

public function validationformAction()
{
    $loginForm = new Application_Form_UserLogin();
    $loginForm->isValidPartial($_POST);
    header('Content-type: application/json');
    $this->_helper->json($loginForm->getMessages());
}
public function loginFormAction()
{
    $this->_helper->layout()->disableLayout();
    //$this->_helper->viewRenderer->setNoRender(true);

    $email = $this->getRequest()->getParam('email');
    $password = $this->getRequest()->getParam('password');

    $loginForm = new Application_Form_UserLogin();
    if ($this->getRequest()->isPost())
    {
        /************ Login Form ************/
        if ($loginForm->isValid($this->getRequest()->getParams()))
        {
            $user = $this->_helper->model('Users')->createRow($loginForm->getValues()); 
            $user = $this->_helper->model('Users')->fetchRowByFields(array('email' => $email, 'hash' => $password));

            if($user) 
            {
                Zend_Session::rememberMe(86400 * 14);
                Zend_Auth::getInstance()->getStorage()->write($user);
                $this->getHelper('redirector')->gotoRoute(array(), 'invite');
                return;
            } 
            else {
                // Error message
                $this->view->errorMsg = "<b>password</b> - invalid, please try again! *";
            }               
        }
        else
        {
            // something
        }
    }       
    $this->view->loginForm = $loginForm;
}
  • 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-15T23:39:00+00:00Added an answer on June 15, 2026 at 11:39 pm

    Try the submit method, like this: $(formselector).submit(); But because you used ajax validation, the real problem here that when you submit. I think you can write the separated validation function for the all field, and you can use the ajax callback to submit.

    Or try the jquery.validation http://bassistance.de/jquery-plugins/jquery-plugin-validation/ because it know the ajax server side validation, and auto submit the form when is valid.

    Sry my english, i from hungary 😀

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

Sidebar

Related Questions

I have a little problem in C++ I don't know how to solve. The
I have a little problem with autoconf, I know that you can use configure.ac
I have a little problem that I don't understand. I have a db that
I have a little problem. I don't know how to use the DataSet in
I am struggling with a little strange problem that I don't know how to
I have a little problem with checking my input. I know that there a
I have a problem that i can't solve, i have a little application that
I have a little problem that I haven't been able to find a solution
I have a little newbie problem that I cannot figure out, I am having
I have a little Problem with the app that I'm developing. In the App

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.