Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How To validate Our Form using jquery for textbox alphabets only

Posted on 2011-09-16
4
Medium Priority
?
749 Views
Last Modified: 2012-05-12
I want To validate my form using jquery .Any body there plz help  me out with code
0
Comment
Question by:savsoft
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 500 total points
ID: 36553237
0
 

Author Comment

by:savsoft
ID: 36553254
I want the solution for jquery which can validate the whole form all along
0
 
LVL 40

Assisted Solution

by:Gurvinder Pal Singh
Gurvinder Pal Singh earned 500 total points
ID: 36553264
so, you can set that validation for all the form elements
or

$("input").each(function(){
  $(this).onkeyup(function(){
    $(this).val($(this).val().replace(/[^a-z]/g,''));
  });
});

this will make sure that all textboxes in the form cannot have anything else than alphabets
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36554294
Whatever you might do with jQuery or other client-side validation, you must also do on the server side after the form data has been submitted.  You can use a regular expression something like this to detect unacceptable characters.  You can use preg_replace to change these characters into blanks, NULLs, question marks, etc.

$regex = '/[^A-Z ]/i';
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question