Skip to content

Instantly share code, notes, and snippets.

@sooop

sooop/index.html Secret

Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sooop/e0d99d2f20ccdce97b57 to your computer and use it in GitHub Desktop.
Save sooop/e0d99d2f20ccdce97b57 to your computer and use it in GitHub Desktop.
<!doctype html>
<script src="./lib/mithril.min.js"></script>
<script src="./js/password.js"></script>
var password = {};
password.controller = function() {
this.description = m.prop("");
this.validate = function() {
var t = this.description();
var s = t.match(/^(?=\w{6,}$)(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).*/);
if (s) {
return true;
}
return false;
}
}
password.view = function(ctrl) {
return m('html', [m('body', [m('div', [
m('input[type=text]', {
onkeyup: m.withAttr('value', ctrl.description),
value: ctrl.description(),
style: {
backgroundColor: ctrl.validate() ? "green" : "red"
}
}),
m('input[type=text]', {
readonly: true,
value: ctrl.validate() ? "Pass!" : "Fail!",
style: {
color: ctrl.validate() ? "black" : "red",
}
})
])])]);
}
m.module(document, password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment