Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

Regular Expression allow alpha characters only?

Javascript coding ..

Moderators: macek, egami, gesf

Regular Expression allow alpha characters only?

Postby bobbygerez » Sat Jan 28, 2012 11:56 pm

Hi everyone, I've search google about regular expression that accept alpha characters only and there are alternatives
name starts with an upper case letter:
var re = /^[A-Z][A-Za-z]*$/
var re = /^[A-Z][A-Za-z]{2,}$/ /* to insist on upper case first letter */

I'm a beginner on javascript and I don't know how this code goes on. I know this one works with alpha but I need to know what is test. If I know what is test then I can try this code.Thanks.
Code: Select all
var name1 = "Bob1";
var name2 = "Bob";

function isValidFirstName(fn)
    var re = /^[a-z]+$/i;
    return re.test(fn);

New php-forum User
New php-forum User
Posts: 18
Joined: Mon Jan 23, 2012 7:40 pm

Return to JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.