Skip to content

Commit

Permalink
[WEBSITE-1225] Fix: client-side validation (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
naseberry authored and UsmanAfzal committed May 25, 2017
1 parent c642fbc commit 0e4d96c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
8 changes: 6 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ module.exports = {
"no-unused-vars": [
"warn"
],
"no-undef": 0,
"no-console": 0,
"no-undef": [
"warn"
],
"no-console": [
"warn"
]
}
};
19 changes: 11 additions & 8 deletions src/javascripts/button_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
// Grab elements with id of search_box
input = document.getElementById('input');

// Create event listener for 'return' keydown and send it as click event
btnLoad.addEventListener('keydown', function (event) {
if (event.keyCode === 13) {
event.target.click();
}
}, false);
// Only create the event listener if the element exists within DOM
if (typeof (btnLoad) != 'undefined' && btnLoad != null) {
// Create event listener for 'return' keydown and send it as click event
btnLoad.addEventListener('keydown', function (event) {
if (event.keyCode === 13) {
event.target.click();
}
}, false);

// Create click event listener
btnLoad.addEventListener('click', btnState, false);
// Create click event listener
btnLoad.addEventListener('click', btnState, false);
}

function btnState() {
// If HTML5 attribute validation passes
Expand Down

0 comments on commit 0e4d96c

Please sign in to comment.