欧芹触发空字段错误
parsley trigger an error for an empty field
如何在不提交表单的情况下触发错误消息,因为当我点击一个输入字段而没有输入任何内容时,如果我点击输入字段以外的地方,它会触发一个验证错误,指出这个字段不能是空的。我尝试使用 'data-parsley-trigger="keyup"' 但只有在输入字段中输入内容时才有效
例如,如果您单击此网站上的标题字段 https://deals.jumia.cm/en/posts/new 并且没有在该字段中输入任何内容而您单击标题字段外,则会触发验证错误
<form method="post" class="ad-form" enctype="multipart/form-data" data-parsley-validate >
<label for="title">Title</label>
<input type="text" id="title" name="title" placeholder="Title" required="required" data-parsley-maxlength="255" data-parsley-maxlength-message="Title can't have more than 255 signs." data-parsley-required-message="Please enter a title." data-trigger="focus" data-toggle="popover" data-content="Keep the title short and clear. Do not write the price in it or any information that is not relevant." data-parsley-validate-if-empty data-parsley-trigger="keyup"/>
<script>
$(document).ready(function(){
$('[data-toggle="popover"]').popover();
});
$('.popover-dismiss').popover({
trigger: 'focus'
})
</script>
<label for="category">Category</label>
<select id="Category" name="category" required="required" data-parsley-required-message="Please select a Category." data-level="0">
<option value="">Select Category</option>
</select>
<label for="subcategory">Subcategory</label>
<select id="Subcategory" name="subcategory" data-parsley-required-message="Please select a subcategory.">
<option value="">Select Category first</option>
</select>
</form>
使用data-parsley-trigger="blur"
和data-parsley-validate-if-empty=true
。
如何在不提交表单的情况下触发错误消息,因为当我点击一个输入字段而没有输入任何内容时,如果我点击输入字段以外的地方,它会触发一个验证错误,指出这个字段不能是空的。我尝试使用 'data-parsley-trigger="keyup"' 但只有在输入字段中输入内容时才有效
例如,如果您单击此网站上的标题字段 https://deals.jumia.cm/en/posts/new 并且没有在该字段中输入任何内容而您单击标题字段外,则会触发验证错误
<form method="post" class="ad-form" enctype="multipart/form-data" data-parsley-validate >
<label for="title">Title</label>
<input type="text" id="title" name="title" placeholder="Title" required="required" data-parsley-maxlength="255" data-parsley-maxlength-message="Title can't have more than 255 signs." data-parsley-required-message="Please enter a title." data-trigger="focus" data-toggle="popover" data-content="Keep the title short and clear. Do not write the price in it or any information that is not relevant." data-parsley-validate-if-empty data-parsley-trigger="keyup"/>
<script>
$(document).ready(function(){
$('[data-toggle="popover"]').popover();
});
$('.popover-dismiss').popover({
trigger: 'focus'
})
</script>
<label for="category">Category</label>
<select id="Category" name="category" required="required" data-parsley-required-message="Please select a Category." data-level="0">
<option value="">Select Category</option>
</select>
<label for="subcategory">Subcategory</label>
<select id="Subcategory" name="subcategory" data-parsley-required-message="Please select a subcategory.">
<option value="">Select Category first</option>
</select>
</form>
使用data-parsley-trigger="blur"
和data-parsley-validate-if-empty=true
。