More general validation js