custom validator cannot work when using ajax
See original GitHub issueHi, I want to use custom validator to validate if the username is in database, however, when I use callback in validate functions, it cannot work, and always return false
<MyInput name='name' title='name' validations={{
nameExistenceCheck: function (value) {
if (value.name === undefined || value.name.length < 5) {
return false;
} else {
// ajax
DataSource.isNameExisted(value.name, function (response) {
if (response.data.msg === 'available') {
return true;
}
})
}
}
}} validationError='Length less than 5 or the name is already existed!'/>
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Custom Validation not working with Ajax MVC Call
The problem is that the submit action is executing without waiting for the response of the custom validation which return false. Any idea...
Read more >custom validators not working from inside AJAX update panel
I have a webform containing custom validator inside AJAX update panel and a button control inside another AJAX update panel. When user clicks...
Read more >CustomValidator Not Working with RadEditor - Telerik
I have this code <asp:CustomValidator id="valreqEditComment" ControlToValidate="reEditComment" ClientValidationFunction="TestWordCount"
Read more >Custom validation on ajax request - WordPress.org
Hello, I would like to hook on ajax validation of the form and display some custom errors by some extra checks i am...
Read more >Getting Data from Users: Validating Input - Yii Framework
To enable AJAX validation for a single input field, configure the enableAjaxValidation property of that field to be true and specify a unique...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The example would work for
onSubmit
, howeveronChange
doesn’t provide aninvalidate
in the args it passes to the handler.It is possible to set validation errors on the form component as an alternative to calling invalidate. Unfortunately, doing so appears to override the built-in validation at the component level.
Let me know if is needed to discuss this more!