/*
    Copyright (c) DigitalPeers.  All rights reserved.
 
    Module Name:

        form_validation_lib.js

    Abstract:

        Functions for validating form fields.

    Environment:

        Apache Server

    Revision History:

        Amit Aides Jan 11 2006 - Created.

*/                      



//
// Validates that the field value string has one or more characters in it.
//
function isNotEmpty(elem)
{
    var str = elem.value;
	
    var re = /.+/;
	
    if(str.match(re))
        return true;

     return false;
 }



//
// Validates that the entry is a positive or negative number.
//
function isNumber(elem)
{
    var num = elem.value;
	
    var re = /^[-]?\d*\.?\d*$/;
	
    str = num.toString();
	
    if (str.match(re))
        return true;

    return false;
}



//
// Validates that the entry is formatted as an email address.
//
function isEMailAddr(elem)
{
	if (!isNotEmpty(elem))
		return false
	
    var str = elem.value;
	
    var re = /^\s*[\w\.\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~]+@\w+[\w\.\-]*\s*$/;
	
    if (str.match(re))
        return true;

    return false;
}



