
/**
 * Is a valid email address.
 * @return bool
 */
function isEmail(str) {
	return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(str);
}

/**
 * Is a valid URL.
 * @return bool
 */
function isURL(str) {
	return /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/.test(str);
}

/**
 * Format decimal number to French number.
 * @example "1250.75" to "1 250,75"
 * @param number Decimal number
 * @return string French number
 */
function format_french_number(number) {
	
	number += '';
	x = number.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ' ' + '$2');
	}
	var with_space = x1 + x2;

	return with_space.replace(".", ",");
}

