Client-side js to validate input