Last active
January 1, 2016 17:49
-
-
Save roseforyou/8179144 to your computer and use it in GitHub Desktop.
MBSJ Login Page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="MBSJ Login Page" /> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> | |
<meta charset=utf-8 /> | |
<title>Login Page</title> | |
</head> | |
<body> | |
<form action="#" id="_js_form"> | |
e-mail: <input id="_js_email" type="text" ><br> | |
passWord:<input id="_js_psd" type="password" ><br> | |
</form> | |
<input id="_js_signIn" type="button" value="Sign-in"> <a href="#">Sign-up</a><br> | |
<a href="#">I Forgot a my passsword</a> | |
<script type="text/javascript"> | |
if(typeof MBSJ === 'undefined'){ | |
var MBSJ = {}; | |
} | |
jQuery(function($){ | |
MBSJ.signIn = function(opt){ | |
var opt = $.extend({ | |
email: '#_js_email', | |
psd: '#_js_psd', | |
signIn: '#_js_signIn', | |
form: '#_js_form' | |
}, opt); | |
var $email = $(opt.email); | |
var $psd = $(opt.psd); | |
var $signIn = $(opt.signIn); | |
var $form = $(opt.form); | |
var mailReg = /^[a-z]([a-z0-9]*[\.\-\_]?[a-z0-9]+)*@([a-z0-9]+[\-\_]?[a-z0-9]*)+[\.][a-z]{2,3}(([\.][a-z]{2})?)$/i; | |
var formCheck = function(){ | |
if( !$.trim($email.val()) ){ | |
alert('IDを入力してください'); | |
$email.focus(); | |
return false; | |
} else if( !mailReg.test( $.trim($email.val()) ) ){ | |
alert('Emailの形式が正しくありません'); | |
$email.focus(); | |
return false; | |
} | |
if( !$.trim($psd.val()) ){ | |
alert('パスワードを入力してください'); | |
$psd.focus(); | |
return false; | |
} | |
$form.submit(); | |
}; | |
$signIn.on('click', formCheck); | |
$email.on('keydown', function(e){ | |
if( e.keyCode == 13 ) { | |
$psd.focus(); | |
} | |
}); | |
$psd.on('keydown', function(e){ | |
if( e.keyCode == 13 ) { | |
formCheck(); | |
} | |
}); | |
}; | |
}); | |
jQuery(function($){ | |
MBSJ.signIn(); | |
}); | |
</script> | |
<!-- | |
</body> | |
</html> | |
--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment