I have a div which is invisible by default. I want, when button click it shows up.
I have tried, but the problem is it shows for just seconds and then again hide.
Here is my code:
function validate() {
var ta = document.getElementById("t").value;
var oa = document.getElementById("oa").value;
var ob = document.getElementById("ob").value;
var oc = document.getElementById("oc").value;
var od = document.getElementById("od").value;
if (ta == "") {
alert("Title can't be null");
document.getElementById("t").style.borderColor = "#E34234";
return false;
}
if (oa == "" && ob == "") {
alert("Atleast two options are compulsory");
document.getElementById("oa").style.borderColor = "#E34234";
document.getElementById("ob").style.borderColor = "#E34234";
return false;
}
document.getElementById("g").style.visibility="visible";
return true;
}
Div id is 'g' and on submit button function validate() is called which validates the form and also show the div.
validate()function is run, it should show you the div with idg. There is no code written in here which will hide it. Or is there a page refresh happening?validate, all attempts to answer would be at best guesswork.