Validating input in java script