add js validation function