1
0
mirror of https://gitee.com/coder-xiaomo/flashsale synced 2025-01-11 12:18:22 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
flashsale/frontend/static/js/common/form-validation.js

39 lines
1.4 KiB
JavaScript

/**
* form validation
*/
function formValidation(_element){
if(_element.next('.help-block').length<1){
var $help_block=$('<span class="help-block"></span>');
$help_block.insertAfter(_element);
}
// 验证错误
if(!_element.valid()){
_element.next('.help-block').children('.iconfont.success').remove();
if(_element.next('.help-block').children('.iconfont').length<1){
var $error_icon=$('<i class="iconfont fl error" >&#xe601;</i>');
$error_icon.insertBefore(_element.next('.help-block').children('h5'));
}
}
// 验证成功
else{
_element.next('.help-block').children('.iconfont.error').remove();
if(_element.next('.help-block').children('.iconfont').length<1){
var $success_icon=$('<i class="iconfont fl success" >&#xe605;</i>');
$success_icon.insertBefore(_element.next('.help-block').children('h5'));
}
}
}
function errorMessageShow(error,element){
if(element.next('.help-block').length<1){
var $help_block=$('<span class="help-block"></span>');
$help_block.insertAfter(element);
}
error.appendTo(element.next('.help-block'));
element.next('.help-block').children('.iconfont.success').remove();
if(element.next('.help-block').children('.iconfont').length<1){
var $error_icon=$('<i class="iconfont fl error" >&#xe601;</i>');
$error_icon.insertBefore(element.next('.help-block').children('h5'));
}
}