i.one i.one - 7 months ago 47
jQuery Question

jquery validation condition prevent submit

how to create jquery for prevent form submit if status=1(from database)
can't submit else can submit,where status i get from database.i'm so confused?

<form class="form-horizontal" id="myAnchor" method="post" action="<?php echo base_url(); ?>actrecord/add/<?php echo $data[0]->activity_id;?>">

<th><button onclick="warning()" type="submit" class="btn blue">new activity</button></th>

document.getElementById("myAnchor").addEventListener("click", function(event){

<script>function warning(){ alert("selesaikan dulu aktiiftas sebelumnya");} </script>


Add an onsubmit trigger in your form:

<form method='POST' action='blah' onsubmit='return check()'>

Then, in javascript with jquery:

function check()
           return (data==1)? false : true;

Just make sure checkStatus.php will echo the status from the db.