如何在元素值为null时显示克隆行中的span.error [英] How to show span.error in cloned row when element value is null
本文介绍了如何在元素值为null时显示克隆行中的span.error的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,
这里是一个popupform,它有一行有两个下拉列表,
i成功克隆此行,当我点击新克隆行更新时按钮我要检查这个es它在下拉列表中有任何选定的值,或者它是nullORempty
我尝试了什么:
Hi friend ,
here is a popupform and its have a row with two drop down list ,
i clone this row successfully and when i click on new clone row update button i want check this e.s its have any selected value in dropdown list or it is nullORempty
What I have tried:
$(document).on('click', '.u', function () {
var $Cont_sr = $(this).closest("tr").find('.new_cont').val().trim();
var m_c11 = $(this).closest("tr").find('.cnttxt').val().trim();
var m_c21 = $(this).closest("tr").find('.cntnum').val().trim();
var m_c31 = m_c11 + m_c21;
$(this).closest("tr").find('.contval1').append(m_c31);
$(this).closest("tr").find('.contval1').val(m_c31);
var NewcontType = $(this).closest("tr").find('.ContTp1').val().trim();
alert(NewcontType);
var isAllValid = true;
if ($('.ContTp1').val() == "") {
$(this).closest("tr").find('span.orderItemsError1').text("Plese Select Container Type From DropDown List ");
isAllValid = false;
$('.ContTp1',this).siblings('span.orderItemsError1').css('visibility', 'visible');
// hire i need show span error
}
else {
$('.ContTp1', this).siblings('span.orderItemsError1').css('visibility', 'hidden');
}
if (isAllValid) {
alert("ok");
}
else{
alert("not ok");
});
弹出窗体html(克隆行)
popup form html (clone row )
<div id="contItems" class="newr1">
<table class="table table-responsive table-hover table-bordered" id="contdetailsItems"><tbody></tbody></table>
<span id="orderItemsError" class="orderItemsError1" style="color:red"></span>
</div>
推荐答案
(文件).on('click','。u',function( ){
var
(document).on('click', '.u', function () { var
Cont_sr =
Cont_sr =
(this).closest(tr)。find('。new_cont')。 val()。trim();
var m_c11 =
(this).closest("tr").find('.new_cont').val().trim(); var m_c11 =
这篇关于如何在元素值为null时显示克隆行中的span.error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文