验证输入框和文本区域
Validation input box and textarea
我想用 jQuery 验证此选项卡内容,我想用 id='lang2'
验证第二个 div。我怎样才能做到这一点?
<div class="tab-content ">
<div id="lang1" class="tab-pane ">
<div class="col s12">
<div class="form-group " id="lang_name">
<input class="form-control contact-method" placeholder="Enter property name" name="name[1]" type="text">
<label for="name[1]">Property name</label>
</div>
</div>
<div class="col s12">
<textarea class="hidden desc-content contact-method" name="description[1]" cols="50" rows="10"></textarea>
<label for="require" class="error-input"> Please enter your description* </label>
</div>
</div>
<div id="lang2" class="tab-pane active ">
<div class="col s12">
<div class="form-group " id="lang_name">
<input class="form-control contact-method" placeholder="Enter property name" name="name[2]" type="text">
<label for="name[2]">Property name</label>
<textarea class="hidden desc-content contact-method" name="description[1]" cols="50" rows="10"></textarea>
</div>
</div>
这对你有用。
$('#submit').on(click, function () {
$('#lang2').find("input[type=text],textarea").each(function (e)
{
if ($(this).val().trim() === "")
{
Alert('Please Enter Value')
return false;
}
}
});
我想用 jQuery 验证此选项卡内容,我想用 id='lang2'
验证第二个 div。我怎样才能做到这一点?
<div class="tab-content ">
<div id="lang1" class="tab-pane ">
<div class="col s12">
<div class="form-group " id="lang_name">
<input class="form-control contact-method" placeholder="Enter property name" name="name[1]" type="text">
<label for="name[1]">Property name</label>
</div>
</div>
<div class="col s12">
<textarea class="hidden desc-content contact-method" name="description[1]" cols="50" rows="10"></textarea>
<label for="require" class="error-input"> Please enter your description* </label>
</div>
</div>
<div id="lang2" class="tab-pane active ">
<div class="col s12">
<div class="form-group " id="lang_name">
<input class="form-control contact-method" placeholder="Enter property name" name="name[2]" type="text">
<label for="name[2]">Property name</label>
<textarea class="hidden desc-content contact-method" name="description[1]" cols="50" rows="10"></textarea>
</div>
</div>
这对你有用。
$('#submit').on(click, function () {
$('#lang2').find("input[type=text],textarea").each(function (e)
{
if ($(this).val().trim() === "")
{
Alert('Please Enter Value')
return false;
}
}
});