Ruslan Ulanov’s Codeshack

The developer’s notebook

Archive for the ‘JavaScript’ tag

Useful JavaScript Regular Expression Functions

leave a comment

Here’s a few links for commonly used REGEXs..

10+ Useful JavaScript Regular Expression Functions to improve your web applications efficiency

[javascript]// check that an input string looks like a valid email address.

var isEmail_re = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
function isEmail (s) {
return String(s).search (isEmail_re) != -1;
}[/javascript]

 
 

[javascript]// returns a string with everything but the digits removed. Could be used to validate phone numbers, etc.

function getdigits (s) {
return s.replace (/[^\d]/g, “”);
}
[/javascript]

Written by Ruslan Ulanov

September 4th, 2009 at 12:16 pm

Posted in JavaScript

Tagged with ,

Using Regular Expressions in YUI CellEditor

leave a comment

Here’s a nice example of validating data in DataTable’s CellEditor using regular expressions.

http://www.satyam.com.ar/yui/2.6.0/invoice.html

Written by Ruslan Ulanov

January 28th, 2009 at 2:35 pm

Posted in JavaScript

Tagged with ,