2016-12-12 1 views
0

私は自分のアプリケーションにブートストラップ検証を使用しています。ユーザーが検証メッセージを表示する方法をテキスト入力の下に「ABC」を入力した場合包みなさい、入力された値は、下のABCに入ると、これは私のコードの下jsfiddleで手動でBootStrapをトリガする方法テキスト入力イベントのぼかしの検証

$('#taginsertform').bootstrapValidator(
{ 
     feedbackIcons: 
     { 
       valid: 'glyphicon glyphicon-ok', 
       invalid: 'glyphicon glyphicon-remove', 
       validating: 'glyphicon glyphicon-refresh' 
     }, 
     fields: 
     { 
       recipientname: 
       { 
         feedbackIcons: 'false', 
         validators: 
         { 
           notEmpty: 
           { 
             message: 'Reciepnt Name cannot be empty' 
           } 
         } 
       } 
     } 
}).on('success.form.bv', function(e) 
{ 
     e.preventDefault(); 
     addTagSbmt(); 
}); 

function addTagSbmt() 
{ 
    $('#taginsertform').bootstrapValidator('resetForm', true); 
     $('.closemodal').trigger('click'); 

     return false; 
} 
$('#myModal').on('shown.bs.modal', function() 
{ 
     $('#taginsertform').bootstrapValidator('resetForm', true); 
}); 


$("#recipientname").blur(function() { 

    var recipientnameval = $("#recipientname").val(); 

    recipientnameval = recipientnameval.toLowerCase(); 

    if(recipientnameval==='abc') 
    { 
    alert(recipientnameval); 
    // fire bootstrap valdation as invalid data 
    } 

}); 

ある

を許可されていません

テキスト入力メッセージを表示するにはどうしたらいいですか? http://jsfiddle.net/xmrxbL9f/97/

答えて

1

ぼかしにエラーdivを追加できます。それがあなたの要求に合っていれば試してください。手動

$("#recipientname").blur(function() { 

    var recipientnameval = $("#recipientname").val(); 

recipientnameval = recipientnameval.toLowerCase(); 
var errorDiv = "<div class='form-error alert alert-danger fade in'>Please Insert valid data<div>" 
if(recipientnameval==='abc') 
    { 
    $('.form-group').append(errorDiv); 
    }else{ 
    $('.form-error').remove(); 
    } 
}); 

運のベスト:)

+0

どうもありがとうございました。、.... – Pawan

+0

ではなく、これを行うには、このためのブートストラップからの方法で構築された使用することが可能ですか? – Pawan

関連する問題