Click here to Skip to main content
15,892,298 members

Response to: I need a Regular expression for alphabet and space

Revision 3
Try this..


This is the javascript that i have used and its working.Try with this


C#
function checkregex() {
            if (!form1.TextBox1.value.match(/^[a-zA-Z ]+$/) && form1.TextBox1.value != "") {
                form1.TextBox1.value = "";
                form1.TextBox1.focus();
                alert("Please Enter only alphabets in text");
            }
        }

here is the regexx to validate one or 2 words with a whitespace between them

(/^[a-zA-Z0-9]+ ?([a-zA-Z0-9]+$){1}/)

Note : you cannot have a whitespace at the end if it is only one word
Try and let me know u got it or not
Posted 11-Nov-12 18:35pm by Divya RS.