JSFiddle - React, Tailwind, and code Playground
HTML
<form method="POST" name="form" action="index2.php">
<table>
<!--for each PHP-->
<tr>
<td><input type='checkbox' name='dirid[]' value='phpResult'/></td>
<!--other fields-->
</tr>
<!-- END for each PHP-->
</table>
<input type="submit" name="add" value="Add" />
<input type="submit" name="edit" value="Edit" />
<input type="submit" name="delete" value="Delete" />
</form>
JavaScript
$(document).ready(function(){
$("form").submit(function() {
var a = false;//here the condition you want if true will submit
if (a) {
alert("YES");
return true;
}else{
alert("NO");
return false;
}
});
});