0

I have bootstrap modal popup with Message box. I have write some conditions on form submit but i want to validate same form with form submit

<form action="" method="post" onSubmit="popUpToggle();" id="myModal2" >
<div class="form_fields feedbackfield">
<textarea id="txtMessage" name="txtMessage" rows="5" class="form-control contact-input" placeholder="Message *" required></textarea>
</div>
<div class="form_fields">
<input type="submit" class="contact-submit" name="SUBMIT" value="SUBMIT">
</div>
</form>

And Script is

<script>
setTimeout(function() {
            if(localStorage.getItem("modalPopup")){$("#myModal2").modal('hide');}
            else{$('#myModal2').modal('show');}

        }, 5000);

        function popUpToggle(){
            localStorage.setItem("modalPopup", "commit");
        }
</script>
user2172424
  • 51
  • 1
  • 10
  • Do one thing. First validate the form then setItem to localstorage. –  Aug 17 '17 at 07:13
  • Yes i did but it not even trigger – user2172424 Aug 17 '17 at 07:17
  • http://jsfiddle.net/aGJrZ/9/ –  Aug 17 '17 at 07:17
  • $("#myModal2").validate({ rules: { txtMessage: { required: true, minlength: 8 }, }, messages: { txtMessage: { required: "Please enter some data", minlength: "Your data must be at least 8 characters" }, } }); }); – user2172424 Aug 17 '17 at 07:17
  • Possible duplicate of [How to correctly validate a modal form](https://stackoverflow.com/questions/34999531/how-to-correctly-validate-a-modal-form) –  Aug 17 '17 at 07:20

0 Answers0