Permalink
Browse files

Disable autocomplete on input elements and make sure the user actuall…

…y typed a message
  • Loading branch information...
1 parent 21e7e35 commit c246903f6ddf8a839704a47d619f4aa548d64e62 @zquestz committed Jul 28, 2012
Showing with 7 additions and 5 deletions.
  1. +2 −2 simplechat.html
  2. +5 −3 simplechat.js
View
@@ -20,7 +20,7 @@ <h1 id="title">SimpleChat</h1>
<form id="register_form">
<div id="warning">{{warning}}</div>
<label>Username: </label>
- <input type="text" id="register" placeholder="Enter Username" />
+ <input type="text" id="register" placeholder="Enter Username" autocomplete="off" />
</form>
</div>
{{/unless}}
@@ -45,7 +45,7 @@ <h1 id="title">SimpleChat</h1>
</div>
</div>
<form id="input_form">
- <input type="text" id="input" placeholder="Enter Message" />
+ <input type="text" id="input" placeholder="Enter Message" autocomplete="off" />
</form>
{{/if}}
</template>
View
@@ -62,7 +62,7 @@ if (Meteor.is_client) {
Template.chat.events = {
'submit form': function (event) {
var inputbox = $('#input'),
- new_message = inputbox.val(),
+ new_message = inputbox.val().replace(/\n/g, '<br />'),
date = new Date(),
hours = date.getHours(),
minutes = date.getMinutes(),
@@ -83,8 +83,10 @@ if (Meteor.is_client) {
var formatted_date = hours + ":" + minutes + " " + suffix;
- Messages.insert({user: Session.get("user"), text: new_message, date: date, formatted_date: formatted_date});
-
+ if (new_message !== '') {
+ Messages.insert({user: Session.get("user"), text: new_message, date: date, formatted_date: formatted_date});
+ }
+
inputbox.val('');
event.preventDefault();

0 comments on commit c246903

Please sign in to comment.