Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Restrict Space and Special Character using Javascript
WhatsApp
Vaibhav Kale
5y
125.7
k
0
1
25
Blog
function
RestrictSpaceSpecial(e) {
var
k;
document.all ? k = e.keyCode : k = e.which;
return
((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
Now access the JavaScript function on keypress event of textbox as shown below:
<
asp:TextBox
ID
=
"TextBox2"
runat
=
"server"
onkeypress
=
"RestrictSpaceSpecial();"
/>
Restrict Space and Special Character on keyboard using Javascript
People also reading
Membership not found