#1
  1. A Change of Season
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,167
    Rep Power
    220

    Jquery validaiton regex


    Hi;

    I have never done this sort of thing. Is this the proper way of validating with Jquery? I wanna allow characters and dash.
    Code:
    $("#txt_firstname").keyup(function ()
    {
    	var rege = /[^a-zA-Z\-]+/;
    	if (rege.test($('#txt_firstname').val()))
    	{
    		alert('First name can only contain characters a to z (or A to Z)');
    	}
    });
    Thanks

    Comments on this post

    • web_loone08 agrees : Yep..., because I do not think jQuery has a native Reguar Expression built into a global API without a Plugin.
    Last edited by English Breakfast Tea; March 18th, 2014 at 12:10 AM.

IMN logo majestic logo threadwatch logo seochat tools logo