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

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -