1. Determine whether the form element exists (1)
if("periodPerMonth" in document.theForm)
{
return true;
}
else{
return false;
}
2. Determine whether the page element exists
if(document.getElementById("XXX"))
{
//Exists
}
3. Determine whether the form element exists (2)
if(document.theForm.periodPerMonth)
{
//Exists
}
or
if(typeof(document.theForm.periodPerMonth)=="object")
{
//Exists
}
4. Determine whether the form exists
if(document.theForm)
{
//Exists
}
5. Write a script with Jquery
if ( $("#someID").length > 0 ) {
$( "#someID").text("hi");
}