I have a small JavaScript code which is called on a button click event.
What I want is just to access an html label property when some validation fails.
I have the following code:
if (datePicker1.get_selectedDate() == null && datePicker2.get_selectedDate() == null) {
//alert("At least one date should be selected");
alert($('#lblValidate').attr('id'));
//$('#lblValidate').css("visibility","visible");
eventArgs.set_cancel(true);
}
I commented out some code for a moment.
The first alert works, however when trying to display an alert to show a label's id property, alert is not shown.
This is the label:
<label id="lblValidate" style="visibility:visible; color:red;">Enter a valid date</label>
What I eventually want to accomplish is have a label hidden and then when the validation fails, to set the label's css to visible, instead of showing an alert.
But, somehow, I cannot display a label attribute in the alert at all.
What am I doing wrong?