There is requirement in my ASP web page to have a textbox below that a ASP button is there to insert the data into database which needs to be filled by user,
on click of button verifying whether he filled data in the textbox using javascript function.
this call to function given to button as
Button1.Attributes.Add("onclick", "javascript:if(onCheck()==false)return false;");
In javascript verifying that if the textbox in is filled, there is checkbox i need to check it, else need to display him a message to fill data that textbox.
to verify that in javascript the following function i am using.
function onCheck() {
var cb1 = document.getElementById('<%=cbRow1.ClientID%>');
var txt1 = document.getElementById('<%=TextBox1.ClientID%>').value;
if (txt1.length != 0)
{
cb1.checked = true;
return true;
}
else{
alert("Enter text in txt1");
return false;
}
}
and in .cs file checking if the hidden check box is checked i am inserting data of the textbox into database.
But the probelm is that check box is not getting checked though data is there in the text box, if i see the check box checked value using debug point, it is false.
Please suggest me solutions to solve this.