i have text box for search operation on user control.i have created java script for alert message if text box is empty. problem is that when any text box is empty alert message get called .......
need help plzzzzzzzz..................
Search Option
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.

vivek kulkarni132 reputationPosted May 7, 2009, 3:59 AM EDT
Hi,
I would suggest using the asp.net validation controls.
http://msdn.microsoft.com/en-us/library/aa479013.aspx
http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=46
However if you want you can validate using javascript.
Anupama Singh134 reputationPosted May 7, 2009, 4:58 AM EDT
thanks for repply......
But you are not getting my ques
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted May 7, 2009, 10:38 PM EDT
Anupama Singh134 reputationPosted May 7, 2009, 11:09 PM EDT
val = event.keyCode;
textboxSearchValue=document.getElementById('<%=textBoxSearchWord.ClientID%>');
// if(!e) var e = window.event;
// if (e.keyCode) code = e.keyCode;
// else if (e.which) code = e.which;
//code contains the pressed key in all browsers
//alert("A) code is: " + code)
//if(document.getElementById('ctl00_horMenu_textBoxSearchWord.ClientID')){
if(textboxSearchValue.value=="" && val==13)
{
alert("Please Enter Text for search");
return false;
}
else
return true;
}
I call this javaScript on key press of search textbox