model validation and javascript to a better behavior