1
I have a text box and a button . I just want to check the value of the text box 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?
Preserving good practices, it would be interesting to put a false Return in the Tring() function, because if not hitting with the expression will not return anything, it will result in a Undefined. But your solution, I believe, solves his problem.
– Duque