Ruby On Rails: ClientSideValidation : validation message persists after you change value programaticallyils

You use Rails4ClientSideValidation gem to validate you forms.
 

Problem:

When you programatically change the values of the required fields or any fields with some sort of validation such as ’email’ or ‘phone_number’, the validation message does not disappear.

Solution:

 $targetFields.on('focusout', function () {
   $(this).trigger('focusin');
   $(this).val(valueYouWant);
   $(this).trigger('change');
   $(this).trigger('blur');
 }

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s