123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- function Login(){
- window.location.href='/login';
- };
- $(function (){
- var firstname = $("input[name='firstname']");
- var lastname = $("input[name='lastname']");
- var email = $("input[name='email']");
- var phone = $("input[name='phone']");
- var username = $("input[name='username']");
- var password = $("input[name='password']");
- var confirmpwd = $("input[name='confirmpwd']");
- var status = false;
- var form = $("form");
- firstname.blur(function(){ // rita blur 取消焦點時
- var span = $("#firstname-span");
- if(firstname.val() == ''){
- span.text("Field is requied");
- status = false;
- }else{
- span.text("");
- status = true;
- };
- });
- lastname.blur(function(){
- var span = $("#lastname-span");
- if(lastname.val() == ''){
- span.text("Field is requied");
- status = false;
- }else{
- span.text("");
- status = true;
- };
- });
- email.blur(function(){
- var span = $("#email-span");
- if(email.val().indexOf('@') == -1){
- span.text("Incorrect email address");
- status = false;
- }else{
- span.text("");
- status = true;
- $.get('/check_email','email='+email.val(),function(resText){
- if(resText.errMsg){
- $("#firstname_span").text("This email is already registered");
- status = false;
- }else{
- $("#firstname_span").text("");
- status = true;
- };
- },'json');
- };
- });
- phone.blur(function(){
- var span = $("#phone-span");
- if(phone.val().length < 8 || isNaN(phone.val()) == true){
- span.text("Wrong phone number");
- status = false;
- }else{
- span.text("");
- status = true;
- };
- });
- username.blur(function(){
- $.get("/check_username","username="+username.val(),function(resText){
- if(resText.errMsg){
- $("#firstname-span").text("This username is already registered");
- status = false;
- }else{
- $("#firstname-span").text("");
- status = true;
- };
- },'json');
- });
- confirmpwd.blur(function(){
- var span = $("#password-span");
- if(password.val() != confirmpwd.val()){
- span.text("Passwords does not match");
- status = false;
- }else{
- span.text("");
- status = true;
- };
- });
- form.submit(function(){
- if((status == true) && (password.val() != '') && (confirmpwd.val() != '')){
- return true;
- }else{
- alert("Please type your infomation");
- return false;
- };
- });
- });
|