1

I have this template.

<div class="estimate">    
    <form id="form1">
        <input type="text" name="text" required>
    </form>
    <a href="javascript:void(0)" id="calculate-btn" class="button">Calculate</a>
</div>

I want to validate text input after clicking to the Calculate button. I tried this, but it doesn't work:

<script>
    requirejs([
        'jquery',
        'jquery/validation'
    ], function($) {
        $("a#estimate-calculate-btn").on("click", function () {
            $("#form1").validate();
        });
    });
</script>

Please help me through this problem.

And if there is any extra information needed, please tell me.

Thanks in advanced!

1

Try this One, I hope this is usefull for you.. I think syntax error in script.

      <script>
        requirejs([
            'jquery',
            'jquery/validation'
        ], function ($) {
            //Your code lines should be here   
            $("a#estimate-calculate-btn").on("click", function () {
                $("#form1").validate();
            });
        });
    </script>
  • I did as you suggested, but it still didn't work. – Tyler Bean Sep 12 '16 at 2:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.