Skip to content

Instantly share code, notes, and snippets.

@sooop

sooop/index.html Secret

Last active Aug 29, 2015
Embed
What would you like to do?
<!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
You can’t perform that action at this time.