開発環境
- OS X El Capitan - Apple (OS)
- Emacs (Text Editor)
- JavaScript (プログラミング言語)
- jQuery (Library)
- Safari(Web browser)
Exercises for Programmers: 57 Challenges to Develop Your Coding Skills (Brian P. Hogan 著、Pragmatic Bookshelf)のChapter 4(Making Decisions)、15(Password Validation)を取り組んでみる。
15(Password Validation)
コード(Emacs)
<label for="password0">
What is the password?
</label>
<input id="password0" type="password" >
<br>
<span id="answer0"></span>
<script src="sample15.js"></script>
(function () {
'use strict';
var password = 'abc$123',
input_password = document.querySelector('#password0'),
span_answer = document.querySelector('#answer0'),
display;
display = function () {
var pass = input_password.value,
answer;
if (pass === password) {
answer = 'Welcom!'
} else {
answer = "I don't know you."
}
span_answer.innerText = answer;
};
input_password.onblur = display;
}());
0 コメント:
コメントを投稿