Alert Box
-
I have to check a textbox text and if it is null while clicking the button then i have to show a message on alert box.:confused: Balwan Singh
Write a javascript function And call the function on button click function script() Dim s As String "alert('')" RegisterStartupScript("", s) end function If textbox = "" then Do stuff else script() endif asdfasdfasdfasdfasdfasdfasdfasdfasdfasdf -- modified at 5:32 Monday 1st May, 2006
-
I have to check a textbox text and if it is null while clicking the button then i have to show a message on alert box.:confused: Balwan Singh
Hi, On click of the button call a javascript method in code behind, Below is
.aspx.cs page code:
For eg : Let server control button id be 'btnSave'btnSave.Attributes.Add("OnClick","javascript:return ValidateTextBox();");
.
aspx page code :
function ValidateTextBox()
{
//for eg:let the textbox id be 'txtName'//First check whether the textbox exists if(document.getElementById("txtName")!=null) { if(isEmptyCheck("txtName")==true) { alert("Text box value is empty,please enter value"); return false; } }
}
//function to check whether text box value is empty or not
function isEmptyCheck(X)
{
if((document.forms[0].elements[X].value=="") || (document.forms[0].elements[X].value.substring(0,1) == ' '))
{
return true;
}
return false;
}//end of functionHope this helps you...:)
-
I have to check a textbox text and if it is null while clicking the button then i have to show a message on alert box.:confused: Balwan Singh
Use the RequierdFieldValidator control ;) -------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!