JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.17.0/dist/jquery.validate.min.js"></script>
<form action="" id="form">
<table id="formtable">
<tr>
<th class="f_th">投稿 <span class="req">必須</span></th>
<td class="f_td">
<p>質問文</p>
<input type="radio" name="radio" value="はい" id="yes_"><label for="yes_" class="label"> はい</label>
<input type="radio" name="radio" value="いいえ" id="no_"><label for="no_" class="label"> いいえ</label>
<div id="return_a"></div>
</td>
</tr>
</table>
<div id="button"><a href="#">#button a</a></div>
</form>
JavaScript
$('#button a').click(
function(){
if(checkForm()){
$("#form").submit()
}});
$.validator.addMethod(
"regex",
function(value, element, regexp) {
var re = new RegExp(regexp);
return this.optional(element) || re.test(value);
},
"Please check your input."
);
$("#form").validate({
rules : {
radio: {required: true}
},
messages: {
radio : { required : "選択してください" }
},
errorPlacement: function(error, element) {
if(element.is(':radio'))
{
error.appendTo(element.parent());
}
else{
error.insertAfter(element);
}
}
});
function checkForm() {
return true;
}