Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validating text values #133

Open
docmattman opened this issue Jan 14, 2016 · 2 comments
Open

Validating text values #133

docmattman opened this issue Jan 14, 2016 · 2 comments

Comments

@docmattman
Copy link

I am binding a text input to a model property. When the value changes, I want to save the changes to the server. I have this part done already. However, I need to run some validation on the new value before saving the model. Mostly I want to make sure that the text input isn't empty.

The general idea I'm working on is changing the title of the model in the view. I want to make sure that the new title isn't empty before saving the model back to the server. I have validation set on the server, but I would like to avoid wasting an ajax call to the server, since I already know empty values won't work.

How can I accomplish some simple validation like this when binding form elements to the model?

@docmattman
Copy link
Author

Bump?

@jekuno
Copy link

jekuno commented Jun 9, 2016

Have a look at Backbone.Validation for this and bind the validate call to e.g. a change event of the according input field(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants