@Rich Harris: It seems that the problem with the <button disabled="{{ !(''+foo) || !(''+bar) }}">submit</button>
trick is that the button is enabled at the start, because both foo
and bar
are initially undefined
and ''+undefined
gives the string 'undefined'
. The technique also becomes unwieldy if you have several fields with various validation requirements.
As you may know, Angular has a $invalid
that you can apply to a form, e.g., <button ng-disabled="myForm.$invalid">submit</button>
where myForm
is the form's name
attribute. In Ractive, I guess one could write an isvalid
function and then use <button disabled="{{ !isvalid() }}">submit</button>
but that only works for one form (or is there some way to "attach" it to a particular element?).