Jump to content


Photo

Validação De Tipos


  • Faça o login para participar
Nenhuma resposta neste tópico

#1 hunternh

hunternh

    Novato no fórum

  • Usuários
  • 3 posts
  • Sexo:Não informado

Posted 15/02/2007, 14:31


isNull = function(x)

{

	if((x == 'undefined') || (x == null)){return true;}

	else{return false;}

};



isObject = function(x)

{

	if(!isNull(x))

	{

		if(x.constructor == Object){return true;}

		else{return false;}

	}

	else{return false;}

};



isBoolean = function(x)

{

	if(!isNull(x))

	{

		if(x.constructor == Boolean){return true;}

		else{return false;}

	}

	else{return false;}

};



isArray = function(x)

{

	if(!isNull(x))

	{

		if(x.constructor == Array){return true;}

		else{return false;}

	}

	else{return false;}

};



isString = function(x)

{

	if(!isNull(x))

	{

		if(x.constructor == String){return true;}

		else{return false;}

	}

	else{return false;}

};



isDate = function(x)

{

	if(!isNull(x))

	{

		if(x.constructor == Date){return true;}

		else{return false;}

	}

	else{return false;}

};



isNumber = function(x)

{

	if(!isNull(x))

	{

		if(!isNaN(x) && (x.constructor != Boolean) && (x.constructor != Array)){return true;}

		else{return false;}

	}

	else{return false;}

};



isInteger = function(x)

{

	if(!isNull(x))

	{

		if(isNumber(x))

		{

			if((x%1) == 0){return true;}

			else{return false;}

		}

		else{return false;}

	}

	else{return false;}

};


Edição feita por: hunternh, 15/02/2007, 14:31.





0 user(s) are reading this topic

0 membro(s), 0 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq