JavaScript validator