are you trying to implement the JS validation functions in asp.net application? If Yes, try this one.. use the Js function in the section function CheckValidation() { if (document.getElementById('<%=txtString.ClientID %>').value == '') { Msg = "Enter string..! \n" } } and use the method in the asp.net textbox control as follows: