用于保存数据和重置数据的书面代码。在这种情况下,数据保存成功,但无法重置表单。当我单击铅笔图标时,它会变成软盘并删除图标。如果我单击软盘上的数据将被保存,但是当我单击删除图标数据表将不会被重置。我这样尝试过代码
val gd = GradientDrawable()
gd.shape = GradientDrawable.RECTANGLE
gd.setColor(Color.RED)
gd.cornerRadius = 15.0f
mBinding.actMainTextview.setBackground(gd)
mBinding.actMainTextview.setOnClickListener(object : View.OnClickListener {
override fun onClick(v: View?) {
gd.setColor(Color.YELLOW)
}
})
//Banking details form validation
$(document).ready(function() {
$('.editBankDetailBtn').click(function() {
if ($('.editBankDetail').is('[readonly]')) { //checks if it is already on readonly mode
$('.editBankDetail').prop('readonly', false); //turns the readonly off
$('.editBankDetailBtn').html(
'<span class="glyphicon glyphicon-floppy-disk"> </span>' +
'<span id="reset-form" class="glyphicon glyphicon-remove"> </span>');
// $('.glyphicon-remove')[0].reset();
} else { //else we do other things
var patt = /^([0-9]{11})|([0-9]{2}-[0-9]{3}-[0-9]{6})$/;
var reg = /^[A-Za-z]{4}[0-9]{6,7}$/;
patt.test('acdbdfdsfsf22-333-666666'); // true
var bname_1 = document.getElementById('name').value;
if (bname_1 == "") {
document.getElementById('name').style.borderColor = "red";
return false;
} else {
document.getElementById('name').style.borderColor = "#cccccc";
}
$('.editBankDetail').prop('readonly', true);
$('.editBankDetailBtn').html(
'<span class="glyphicon glyphicon-pencil"> </span>');
$('.glyphicon-remove').on('click', function() {
$("#reset-form").trigger("reset");
});
}
});
});
答案 0 :(得分:1)
您有几件事
name
,而是代码中的bankName
$('.editBankDetailBtn')
$('.editBankDetailBtn').on('click', '.glyphicon-remove', function() {
$("#myForm")[0].reset()
});
答案 1 :(得分:0)
您的点击将不适用于动态创建的点击。添加以下代码
$(document).on('click', '.glyphicon-remove', function() {
// Put one alert or console to check that you here
$("#YOU_FORM_ID")[0].reset(); //
});