I have a text box called Name in a form .The name text box should only accept alphabets and spaces and max length should be only 30 chars.
Can any one share the code with me.
I will be very thank ful for the help!
Hi Hero1234567,
Here is jQuery code. Check this and let me know
$.validator.addMethod("alpha",
function (value, element) {
var alphaRegExp = new RegExp("^[\\sa-zA-Z]{1,30}*$");
if (alphaRegExp.test(element.value)) {
return true;
}
else return false;
},
"Please enter alphabet"
);
chandu123
Contributor
4646 Points
1172 Posts
Re: name text box should only accept alphabets and spaces and max length should be only 30
Nov 29, 2012 09:35 AM|LINK
You can use ajax filtered textbox for this it is easy and simple
Chandrasekhar (MCTS) .NET framework 3.5, ASP.NET Applications
If my ANSWER helps you in solving your problem MARK IT AS ANSWER
Hero1234567
Member
2 Points
25 Posts
Re: name text box should only accept alphabets and spaces and max length should be only 30
Nov 29, 2012 10:09 AM|LINK
Can you give me some code for ajax filtered textbox please?
chandu123
Contributor
4646 Points
1172 Posts
Re: name text box should only accept alphabets and spaces and max length should be only 30
Nov 29, 2012 10:35 AM|LINK
Do you have ajaxcontroltool kit installed in your system?? if not download it here http://ajaxcontroltoolkit.codeplex.com/
and drag a textbox and add the extender then change FilterType="Custom, Numbers"
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/FilteredTextBox/FilteredTextBox.aspx
Chandrasekhar (MCTS) .NET framework 3.5, ASP.NET Applications
If my ANSWER helps you in solving your problem MARK IT AS ANSWER
matifnadeem
Contributor
4606 Points
1094 Posts
Re: name text box should only accept alphabets and spaces and max length should be only 30
Nov 30, 2012 10:14 AM|LINK
Hi Hero1234567,
Here is jQuery code. Check this and let me know
$.validator.addMethod("alpha", function (value, element) { var alphaRegExp = new RegExp("^[\\sa-zA-Z]{1,30}*$"); if (alphaRegExp.test(element.value)) { return true; } else return false; }, "Please enter alphabet" );Cheers
M Atif Nadeem
Mark as Answer if you got right thing
Read my blog | Follow me on LinkedIn
matifnadeem
Contributor
4606 Points
1094 Posts
Re: name text box should only accept alphabets and spaces and max length should be only 30
Nov 30, 2012 10:20 AM|LINK
Hi Hero1234567,
You can perform this functionality using AJAX Filtered Textbox extender. Check this and let me know if any query remains.
Cheers
M Atif Nadeem
Mark as Answer if you got right thing
Read my blog | Follow me on LinkedIn