I have a text box and a button. I just want to check the value of the textbox with javascript and prevent it from displaying if it is null.
Here is aspx:
<asp:TextBox ID="TextBoxName" runat="server"></asp:TextBox>
<asp:Button CssClass="addButtonBlack" ID="ButtonAddDriver" OnClientClick="return IsNull();" OnClick="ButtonAddDriver_Click" runat="server" Text="Ekle" />
And my javascript code:
function IsNull() {
var success = true;
var name = document.getElementById('TextBoxName');
if (name.value == "") {
name.style.borderColor = '#e52213';
name.style.border = 'solid';
success = false;
}
if (success)
return true;
else
return false;
}
The text box is null. How can I prevent this?