javascript - bootbox meteor form: preventing blank submissions -
i have "create new" button linked bootbox modal form asks user input name of new chat room. code looks this:
template.chatslist.events = { 'click .newchat-button': function () { bootbox.prompt("enter title new chat", function(result) { if (result != null) { var validentry = result; rooms.insert({ name: validentry }); } }); } }
however, on blank submit, submission still goes through , room name blank. how can stop happening? tried result.length > 1, etc, no avail.
i'm beginner , appreciate explanation on matter.
how about
if(result && result.length){ .. }
on blank submission, result
value empty string, not null
.
Comments
Post a Comment