Folks!!
I am developing a website, in that showing the field errors in javascript alert()
User is not satisfy with the alert pop-up each time, and I thought to provide it in inline div block
I want to know how I can pass/add bootstrap class property{alert alert-warning} to the error block when I am passing Error Message from the javascript or jquery.
function getValidateField(){
var varName= document.getElementById('txtNameSetting').value;
if(varName.trim().length <= 0){
//alert("Please enter Application Name");
document.getElementById('divErrorBlock').innerHTML = "Please enter Application Name";
document.getElementById('divErrorBlock').style.display = 'block';
//$('#divErrorBlock').show();
return false;
}
else return true;
}
If I pass inside the 'div', it will visible all the time, I need to hide this blcok until it get invoke
Thank in advance
Folks!!
I am developing a website, in that showing the field errors in javascript alert()
User is not satisfy with the alert pop-up each time, and I thought to provide it in inline div block
I want to know how I can pass/add bootstrap class property{alert alert-warning} to the error block when I am passing Error Message from the javascript or jquery.
function getValidateField(){
var varName= document.getElementById('txtNameSetting').value;
if(varName.trim().length <= 0){
//alert("Please enter Application Name");
document.getElementById('divErrorBlock').innerHTML = "Please enter Application Name";
document.getElementById('divErrorBlock').style.display = 'block';
//$('#divErrorBlock').show();
return false;
}
else return true;
}
If I pass inside the 'div', it will visible all the time, I need to hide this blcok until it get invoke
Thank in advance
Share Improve this question asked Mar 24, 2016 at 5:09 Prajwal BhatPrajwal Bhat 3032 gold badges5 silver badges21 bronze badges2 Answers
Reset to default 4Try setAttribute;
document.getElementById('divErrorBlock').setAttribute("class", "alert alert-warning");
or jquery addClass()
$('#divErrorBlock').addClass('alert alert-warning');
or using attr()
$('#divErrorBlock').attr('class','alert alert-warning');
If you can use jquery. It is as simple as this.
$('#divErrorBlock').addClass('alert alert-warning');