Placing Jquery validation error inside <input> box?

2.9k views Asked by At

My problem:

After validating an input field, if validation isn't complete, i want to put the error-message into the orginal input field.

you can user insertAfter() and insertBefore() to, (duh!) insert after or before input field.

I couldn't find any solution to my problem on StackOverFlow.

1

There are 1 answers

0
Pjust On BEST ANSWER

SO HERE IS MY SOLUTION:

THIS SCRIPT PLACES ERROR IN YOUR INPUT ELEMENT!

<script>
  $(document).ready(function() {
        $("#theForm").validate({

            errorPlacement: function(error, element) { 
                element.val(error[0].outerText);
            },
            debug: true
        });
    });

Additionally you will need a script to remove the message when input is clicked.

G'day!