Email Validation from Codebehind
This is for check the email address from codebehind using regular expression.
if (System.Text.RegularExpressions.Regex.IsMatch(txtNewsletter.Text, "^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{1,3})$") == false)
{
Page.RegisterStartupScript("GetType", "<script language='javascript'>alert('Please enter valid email address!')</script>'");
}
Labels: email validation, javascript, JS, regular expression 0 Comments
watermark textbox using Ajax control
This is pretty simple compared to jquery. Since we need refer a dll only. we dont want any script for this. we just include that reference into our website.
Please have a look at the coding.......
<asp:TextBox runat="server" ID="txtSearch"></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID="twSearch" runat="server" TargetControlID="txtSearch"
WatermarkText="Search Products..." />
<span class="search_button">
<asp:ImageButton ID="butSearch1" runat="server" ImageAlign="Right" OnClick="butSearch1_Click"
Height="30px" />
</span>
Labels: .NET, ajax, ajax textbox, DOT Net, Tips, watermark 0 Comments
Watermark Textbox using jquery
Here is the coding for Watermark inside a textbox. That is initially the message will show inside the textbox. Once you click on the textbox it will disappear. This is used by jquery.
CSS:
<style type="text/css" media="screen">
.water
{
font-family: Tahoma, Arial, sans-serif;
color: blue;
}
</style>
SCRIPT:
<script src="js/jquery-1.2.6.min.js" type="text/javascript"></script>
DESIGN:
<div>
<h2>
Watermarked TextBox </h2>
<br />
<asp:TextBox ID="txtFirstName" class="water" Text="Enter First Name" ToolTip="Enter First Name" runat="server"></asp:TextBox><br />
<asp:TextBox ID="txtLastName" class="water" Text="Enter Last Name" ToolTip="Enter Last Name" runat="server"></asp:TextBox> <br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" ValidationGroup="vgNews" /></div>
Please give your comments if you need any clarification.... Also I will post watermark using ajax in the next post... Happy Coding!!!
Recent Comments