jqueryformsvalidationformvalidation-pluginformvalidation.io

reset form validation from in an other form with button


i am using from validation.io but I have a problem. I dont reset field validations form1, it works correcty in form2.

I tryed trigger but didnt work.

how can I do? do you have an idea my friends?

<form id="form1">
    <input type="reset" click="resetForm2()">
</form>

<form id="form2">
    <input id="text1" type="text" value="value">
    <input id="text2" type="text" value="value">
    <input id="text3" type="text" value="value">
    <input id="text4" type="text" value="value">
    .
    .
    .
    <input id="text16" type="text" value="value">
    <input type="reset" click="resetForm2()">
</form>

formvalidation reset metod

function reserForm2()
{
    $('#form2').data('formValidation').resetForm($('#form2'));
}

Solution

  • Add the form="form2" attribute to rest button. Refer to this for details.

    function reserForm2()
    {
        $('#form2').data('formValidation').resetForm($('#form2'));
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <form id="form1">
        <input type="reset" click="resetForm2()" form="form2">
    </form>
    
    <form id="form2">
        <input id="text1" type="text" value="value">
        <input id="text2" type="text" value="value">
        <input id="text3" type="text" value="value">
        <input id="text4" type="text" value="value">
    
        <input id="text16" type="text" value="value">
        <input type="reset" click="resetForm2()">
    </form>