Closed reckerswartz closed 6 years ago
Hi,
Thanks for all those details. Track down CSV issues is time consuming, debugging CSV issues with other frameworks is worse.
data-client-side-validations="{"html_settings..">
Did you voluntarily omit the data-client-side-validations
attribute? it is very important.
For client side validations, you probably need a custom javascript file, something like this: https://github.com/DavyJonesLocker/client_side_validations-simple_form/blob/master/coffeescript/rails.validations.simple_form.coffee
If you are referring to server side validations message after an unsuccesful submit, I think CSV has very little to do with this. ActionView::Base.field_error_proc = proc do |html_tag, instance|
is a Rails thing
Hey, Thank you for the response. as per your guide I made my changes into javascript file as given below.
I am able to receive the message correctly but can't able to put proper validation for presence true. when I use validate presence: true I am able to get the error message of can't be blank but it was not removed when I enter the text until I resolve next validation related to the same field. For example when I keep email input blank and it shows the error "can't be blank" after that I enter the text, it still shows "can't be blank" until I enter the proper email address, where it should be showing invalid email message.
my application form page can found here
window.ClientSideValidations.formBuilders['ActionView::Helpers::FormBuilder'] = {
add: function (element, settings, message) {
// custom add code here
var form = $(element[0].form);
var for_id = element.attr('id');
if (element.data('valid') !== false) {
if (form.find("label.error[for='" + for_id + "']")[0] == null) {
form.find("label[for='" + for_id + "']").addClass('custom-form-error').attr('data-error', message);
element.removeClass("valid");
element.removeClass("validate");
element.addClass("invalid");
element.addClass('custom-form-error');
}
}
return form.find("label.error[for='" + for_id + "']").attr('data-error', message);
},
remove: function (element, settings) {
var form = $(element[0].form);
if (element.hasClass('custom-form-error')) {
var for_id = element.attr('id');
form.find("label[for='" + for_id + "']").removeClass('custom-form-error').removeAttr('data-error');
element.addClass("valid");
element.addClass("validate");
element.removeClass("invalid");
element.removeClass('custom-form-error');
}
return element;
}
}
Hi,
please double check that your remove function is checking that custom-form-error
class is present on the proper element.
Please take another look here: https://github.com/DavyJonesLocker/client_side_validations-simple_form/blob/master/coffeescript/rails.validations.simple_form.coffee
I'm going to close this one, since it looks like a third-party integration question about client side validation rather than an issue
Hey I am working on webapp with framework Materialize Which uses the different method to show the error message. Instead of, showing the message in label , It uses data-error attribute with in the label tag to show in error message.
Example
As per the document changes are need to be done in config/initializers/client_side_validations.rb
but I am unable to do that please guide me to how to changes according to my framework
ClientSideValidations && Rails!
Code snippet from model of the validations
The form code from your template
The resulting HTML
The resulting HTML After validation
Need Result After validation