Showing posts with label set default text in textbox. Show all posts
Showing posts with label set default text in textbox. Show all posts

Thursday, December 1, 2011

Show default Text in textbox asp.net


you can use this functionality to set default text of textbox

 <asp:TextBox ID="txtMinSearch" runat="server"
            ForeColor="GrayText" Text="Enter property name, address or GENIE ID."
            onClick="if(this.value=='Enter property name, address or GENIE ID.')this.value='';"
            onBlur="if(this.value=='')this.value='Enter property name, address or GENIE ID.';"
            ControlToValidate="txtMinSearch" ClientIDMode="Static">
</asp:TextBox>

if you provide validation on textbox by using its default functionality then you controlToValidate property and in CS you should apply regex for validation.


Regex.IsMatch(txtMinSearch.Text, @"^\d+([,][\s]\d+)*$")