That validation code looks perfectly fine, but that's only one piece of the puzzle. I would suggest looking at the Backbone.Validation examples (and the code behind them). The examples offer two different approaches for handling validation rules similar to yours.
Here are the pieces that get the email validation working in the "Basic" scenario. First, a snippet of the template:
<div class="control-group">
<label class="control-label" for="email">Email</label>
<div class="controls">
<input type="text" class="input-xlarge" id="email" name="email" data-error-style="inline">
</div>
</div>
Note that the email input specifies "inline" as the data-error-style. That plays into the default invalid
callback from backbone.validation.bootstrap.js:
else if (control.data("error-style") === "inline"){
if (group.find(".help-inline").length === 0){
group.find(".controls").append("<span class=\"help-inline error-message\"></span>");
}
var target = group.find(".help-inline");
target.text(error);
}
That code adds an error message to the email element, or replaces the error text if an inline error message already exists.
You can check through more of the code to get a handle on what's going on, but the key point is that the model validation parameters are only part of the story. The other pieces are the template setup and valid
/invalid
callbacks.