0

I'm trying to override the validation on jquery to put it inside the form input value (due to the fact that my form does not have space to put it to the side ) is a side panel form.. hence, i want it to show inside the form for hte validation error, does anyone know how to do it? ALthough i can put it underneath, i still want it to be inside the form value.. any help is greatly appreciated, i did find out the function was setDefaults, but any other different ways works to

Santiago Berniz
  • 37
  • 1
  • 11
  • Are you using [this jQuery Validation Plugin](https://jqueryvalidation.org/)? If so, you might find the [errorplacement](https://jqueryvalidation.org/validate/#errorplacement) function useful. – showdev Apr 18 '19 at 09:45

1 Answers1

0
$(document).ready(function(){
    var grabMsg =  $('.YOURDIV').html(); // your div, which contains error message
    var inputName = $('input'); // input where you want it to appear

    if(inputName.val() == '') {
        inputName.attr('value', grabMsg);
    }
});

This is just basic code and you'll need to think about additional things, like how to remove message then user clicks that input or submits a form, 'cause this code sets a value in your input. Be careful before using.

keyser
  • 18,829
  • 16
  • 59
  • 101
Tomas
  • 1