Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
How to prevent remote error message from displaying when using JustValidate remote option?

I am using JustValidate library (https://github.com/horprogs/Just-validate) for form validation. It works perfectly on the client-side, but seems to not work properly when executing remote validation. For instance: If we have an input field "email" the remote validation in our Javascript would look like the code below.

rules: {
    email: {
        email: true,
        remote: {
            url: '@Url.Action("Validate", "ActivityTypes")',
            sendParam: 'email',
            successAnswer: 'OK',
            method: 'GET'
        }
    }
}

Every time user inputs something in the e-mail input, value is sent to server and checked if it's okay or not. The problem is you always get a response OK. And every time you get that response the error message for the input shows (Even if the input has been filled out correctly). My controller action looks like this:

public async Task<IActionResult> Validate(ActivityType values)
    {
        var activityType = await _context.ActivityType
           .FirstOrDefaultAsync(m => m.Name == values.Name);
        if (activityType == null)
        {
           return NotFound();
        }



        return Ok();
}

I have already tried redirecting from one action to another in the controller, returning NotFound() but am still getting the Ok response, and the error message shows up again. When trying the demos on the JustValidate library's GitHub page I noticed that inputs are always showing error messages for the input "email", even when they shouldn't. Has anyone found a workaround? I have already used this library on 80% of all my form and don't want to change it for some other library.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Since you mentioned successAnswer: 'OK' you need to return the response as Content. Like this.

[HttpGet]
[Route("check-exists")]
public IActionResult CheckExists(string email)
{
    return email == "anuraj@example.com" ? Content("Not Okay") : Content("OK");
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda