Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

hunternh

[Resolvido] Validação de tipos

Recommended Posts

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;}};

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.