C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Client Side Validation of New User Name Using Custom Validator.


Posted Date: 03 Sep 2008    Resource Type: Code Snippets    Category: ASP.NET WebForms

Posted By: Geetha       Member Level: Gold
Rating:     Points: 15



The javascript function will check the username character by character.The first Letter of the username should be an alphabet. And the username should contains only the alphanumeric characters. And then set the ClientValidationFunction property of CustomValidator as ClientValidationFunction="ValidateText" and also the controltovalidate property.




JavaScript Fucntion.
function ValidateText(source, clientside_arguments)
{
var txtVal = clientside_arguments.Value;
var len = txtVal.length;
var Search =0;
if(txtVal.charAt(0) < 'A' || txtVal.charAt(0) > 'Z' && txtVal.charAt(0) <'a' || txtVal.charAt(0)>'z')
{
alert("First letter of User Name must be an alphabet");
clientside_arguments.IsValid=false;
}
else
{
for(var i = 0;i<len; i++)
{
if(txtVal.charAt(i) < 'A' || txtVal.charAt(i) > 'Z' && txtVal.charAt(i) <'a' || txtVal.charAt(i)>'z')
Search = Search + 1;
}
if(Search == len)
{
alert("Invalid User Name");
clientside_arguments.IsValid=false;
}
else
clientside_arguments.IsValid=true;
}

}



Properties of The CustomValidator to be set.
ID="cvalUserName" runat="server" ErrorMessage="Invalid User Name." ClientValidationFunction="ValidateText" ControlToValidate="txtusername"




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Web page  .  User Name Validation  .  Javascript  .  Client side  .  Ckient Side  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Preventing Unwanted background colouring of textboxes by google toolbar
Previous Resource: How to Download files using asp.net
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing service

Contact Us    Privacy Policy    Terms Of Use