0

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.

4
  • 2
    You should at first ask a question and then answer it in the answer section not in the question's body, what problem does this solve? Commented Sep 26, 2013 at 9:50
  • so that's removing value filled by user?! As user, i wouldn't expect/want that Commented Sep 26, 2013 at 9:50
  • Undefined: My reputation isn't high enough to answer my own question, a couple of hours, and i can. Commented Sep 26, 2013 at 10:40
  • A.wolff: the script doesn't remove any values filled by user. It puts error message in input field, if input was required and not filled. Commented Sep 26, 2013 at 10:41

1 Answer 1

3

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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.