jQuery-Form-Validator
jQuery-Form-Validator copied to clipboard
Server Validation Overwriting Other Messages
I having a issue with Server messages overwriting other messages and doing search I found https://github.com/victorjonsson/jQuery-Form-Validator/commit/5b67d3b0ea05ce75423c388c90c1d94beec47d5a which is meant to fix it.
As I am using CDNJS for to get the scripts and looking at code in the CDN version is not the same as from the commit
This is the minified code which would covert back (non minified) to the code prior to that commit
f(h,c,b,d, function(b){g.removeClass("validating-server-side"),c.removeClass("validating-server-side"),b.message && c.attr(d.validationErrorMsgAttribute, b.message),a(b.valid)})
Also the code from master has code prior to that commit also.
Could you please tell me more about your problem? You know that server validation can't be combined with other validators?
It does not say it does not work with other validators and seems to work fine except the error message for the other validators is overwritten after the server validation is run.
Currently I have it set to 'required,email,server' an initially required & email so the messages 'This is a required field' & 'You have not given a correct e-mail address' but after the server validation runs it aways shows the server validation error even tho the required and email are validations are being run correctly. See video https://youtu.be/8l4MABG_6Zs
Doing a search I found the issue https://github.com/victorjonsson/jQuery-Form-Validator/issues/502 which referenced this commit https://github.com/victorjonsson/jQuery-Form-Validator/commit/5b67d3b0ea05ce75423c388c90c1d94beec47d5a which is mean to stop server validation message overwriting the other messages, but that code is not currently in the latest version.
What version of the plugin are you using?
I am using version 2.3.77 via this link https://cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.3.77/jquery.form-validator.min.js
I am having similar issues with the plugin, server side validation message overrides all required, length validation message. Is there any way to fix this?
The same thing on v. 2.3.77
I have setup <input data-validation="required,server" ... and both run well in first run.
The issue with overwriting validation error message appears after server validation get responce { valid: false, message: "server check error" }, then clear the input and required validation runs on empty field. As the result the previous "server check error" is displayed.
I've look througth the source code of the security module and find that the general data-validation-error-msg attribute is added to store server validation error message, and according to resolveErrorMessage function, I've tried to change it to module specific attribute: data-validation-error-msg-server
So, I edit security.js after lines: name: 'server', validatorFunction: function ( .....
from:
$input.attr(conf.validationErrorMsgAttribute, response.message);
to:
$input.attr(conf.validationErrorMsgAttribute + '-server', response.message);
and the issue was fixed for my case. Think this helps.