Function that returns true if the num contains a and b digits only
function check ( num , a , b ) { while ( num > 0 ) { var rem = num % 10 ; num = parseInt ( num / 10 ) ; if ( rem != a && rem != b ) return false ; } return true ; }