0
ユーザーが別のフィールドよりも低い/高い値を入力した場合はエラーを表示します。それを行うために検証ルールを使用するにはどうすればよいですか?私はtxtLessthanequalより になるためにはtxtBetween1が必要です。私はまた、txtGreaterequalがtxtBetweenとtxtBetween2以上になるようにして、ユーザがばかばかしい値を入力しないようにする必要があります。jQueryの検証1つのフィールドより多くのフィールド
$(document).ready(function() {
$.validator.addMethod("greaterThan",
function (value, element, param) {
var $otherElement = $(param);
return parseInt(value, 10) > parseInt($otherElement.val(), 10);
});
$("#currencyform").validate({
messages: {
txtFrom: "Currency value is required",
txtTo: "Currency value is required",
txtConversionRate: "Rate must be a number",
txtGreaterEqual: "Rate must be more than between",
txtBetween: "Rate must be number",
txtBetween1: "Rate must be number",
txtLessthanEqual: "Rate must be less than between",
},
rules: {
txtConversionRate: {
min: 1
},
txtGreaterEqual: {
min:
},
txtBetween: {
min: 1
},
txtBetween1: {
min: 1,
greaterThan: "#LessthanEqual"
},
txtLessthanEqual: {
min: 1
},
},
focusInvalid: false,
submitHandler: function() {
return false;
},
errorPlacement: function (error, element) {
error.appendTo(element.parent().parent().after());
},
})
onKeyUp()の使用方法を教えてください。 –
このhttps://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_event_keydown_keyupを参照してください。 –