Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!