当值小于if条件时,我想显示警报(错误消息)
这是我的代码:
$('#submit').click(function() {
if (parseInt($("#pointsid").val()) < parseInt($("#requiredpointid").val())) {
alert("Points is not enough!");
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="col-md-4 bg-warning">必要ポイント</div>
<div class="col-md-8 pd-all-2px">
<input type="text" class="form-control" name="requiredpoint" id="requiredpointid" th:value="${requiredpoint}" required />
</div>
<input type="hidden" name="points" id="pointsid" th:value="${currentUser.points}">
<button type="submit" value="apply" name="submitType" class="btn btn-primary">申請</button>
如果值:
th:value="${currentUser.points}
小于:
th:value="${requiredpoint}
然后显示警报:
(“积分不足”
单击按钮时。