Skip to content

Commit

Permalink
add email duplication check
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Davis committed May 5, 2012
1 parent 9e631b3 commit 050a317
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
44 changes: 26 additions & 18 deletions js/dojo-release-1.7.2-src/larson/login/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ define([

this.dialog.show()

//add the form watcher
var myForm = dijit.byId("registerForm")

myForm.watch('value', function() {
Expand All @@ -58,27 +59,34 @@ define([
dijit.byId("registerButton").setAttribute('disabled', true)
}
})

//add the email validator
var emailAddress = dijit.byId("emailAddress")
connect.connect(emailAddress, "onChange", this.checkEmailAddress)
},
checkEmailAddress: function() {
this.inherited(arguments)
alert("checking email")
this.username = dijit.byId("emailAddress").get("value")

var xhrArgs = {
url: "http://localhost/users/"+this.username,
handleAs: "json",
load: function(data) {
dojo.byId("emailError").innerHTML = "This email is already taken"
dijit.byId("emailAddress").setAttribute("value", "")
},
error: function(error) {
dojo.byId("emailError").innerHTML = ""
connect.connect(emailAddress, "onChange", function() {
//todo - figure out how to not inline this function and make it a mixin
this.username = dijit.byId("emailAddress").get("value")

var xhrArgs = {
url: "http://localhost/users/"+this.username,
handleAs: "json",
load: function(data) {
dojo.byId("emailError").innerHTML = "This email is already taken"
dijit.byId("emailAddress").setAttribute("value", "")
},
error: function(error) {
dojo.byId("emailError").innerHTML = ""
}
}
}

var deferred = dojo.xhrGet(xhrArgs)

var deferred = dojo.xhrGet(xhrArgs)
})

var registerButton = dijit.byId("registerButton")

connect.connect(registerButton, "onClick", function() {
alert("hello there")
})
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
<label for="lastName">Last Name</label><br />
<input name="lastName" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props="required:'true'" />
<br /><br />
<label for="emailAddress">Email address (this will be your login, too!)</label><br />
<input name="emailAddress" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props="required:'true'" id="emailAddress" />
<span id="emailError"></span><br />
<br />
<label for="key">Email address (this will be your login, too!)</label><br />
<input name="key" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props="required:'true'" id="emailAddress" />
<span id="emailError" class="inlineError"></span>
<br /><br />
<label for="password">Enter a password</label><br />
<input name="password" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props="required:'true'" type="password" />
<input name="password" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props="required:'true'" type="password" id="password1" />
<!-- take this out for now
<br /><br />
<label for="password2">Please re-enter your password</label><br />
<input name="password2" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props="required:'true'" type="password" />
<input name="password2" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props="required:'true'" type="password" id="password2" />
<span id="passwordError" class="inlineError"></span> -->
<br /><br />
<button data-dojo-type="dijit.form.Button" id="registerButton" disabled="disabled">Register</button>
<button data-dojo-type="dijit.form.Button" id="cancelButton" data-dojo-props="class:'cancelButton'" onClick="dijit.byId('registerDialog').hide()">Cancel</button>
Expand Down

0 comments on commit 050a317

Please sign in to comment.