// Checks the passed parameter is a valid code or not and the second parameter checks if it is a required field or not

// Do not allow |(pipe), " " (space) characters

// Construct the regular expression with allowed values for some inputs (for eg. allow dots and spaces in titles etc.)

function isCode (s, required, allowed)

{	

	if (required == true)

	{

		if (Trim(s) == "") return false;

	}

	else

	{

		if (Trim(s) == "") return true;

	}

	

	

	if (allowed)

	{

		var codeexp = new RegExp("^([\_a-zA-Z0-9/"+allowed+"])*$","g");

	}

	else

	{

		var codeexp = new RegExp("^([\_a-zA-Z0-9/])*$","g");

	}

	
		

	return codeexp.test(s);

}



