﻿function RuleOutput(name, json) { var rule = json.split(' ')[0].replace('[', '').replace(']', '').split('=')[1]; eval('var z=' + rule); eval('var r=z.' + name); return r } function ValidateForm() { var validated = true; var email = $('#EmailAddress_TextBox1').val(); var watermark = $('#EmailAddress_TextBox1').attr('class').indexOf('watermark'); var regex = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; $('#EmailAddress__error_image').attr('title', ''); $('#EmailAddress__error').hide(); if (email.length == 0 || watermark > 1) { $('#EmailAddress__error_image').attr('title', '* The email address field is required.<br />&nbsp;&nbsp;&nbsp;-Please fill in this field to continue'); $('#EmailAddress__error').show(); validated = false } else if (!regex.test(email)) { $('#EmailAddress__error_image').attr('title', '* The email address supplied does not match a valid mailbox expresion.<br />&nbsp;&nbsp;&nbsp;-Please correct to continue'); $('#EmailAddress__error').show(); validated = false } var username = $('#Username_TextBox1').val(); watermark = $('#Username_TextBox1').attr('class').indexOf('watermark'); $('#Username__error_image').attr('title', ''); $('#Username__error').hide(); if (username.length == 0 || watermark > 1) { $('#Username__error_image').attr('title', '* The username field is required.<br />&nbsp;&nbsp;-Please fill in this field to continue'); $('#Username__error').show(); validated = false } var mobile = $('#MobileNumber_TextBox1').val() + $('#MobileNumber_TextBox2').val() + $('#MobileNumber_TextBox3').val(); var w1 = $('#MobileNumber_TextBox1').attr('class').indexOf('watermark'); var w2 = $('#MobileNumber_TextBox2').attr('class').indexOf('watermark'); var w3 = $('#MobileNumber_TextBox3').attr('class').indexOf('watermark'); watermark = w1 + w2 + w3; $('#MobileNumber__error_image').attr('title', ''); $('#MobileNumber__error').hide(); if (mobile.length == 0 || watermark > 1) { $('#MobileNumber__error_image').attr('title', '* The mobile number field is required<br />&nbsp;&nbsp;-Please fill in this field to continue'); $('#MobileNumber__error').show(); validated = false } else if (mobile.length < 9) { $('#MobileNumber__error_image').attr('title', '* The mobile number supplied is invalid<br />&nbsp;&nbsp;-Please correct to continue'); $('#MobileNumber__error').show(); validated = false } var pass = $('#Password_TextBox1').val(); var rule = $('#Password_TextBox1').attr('class'); watermark = rule.indexOf('watermark'); $('#Password__error_image').attr('title', ''); $('#Password__error').hide(); if (pass.length == 0 || watermark > 1) { $('#Password__error_image').attr('title', '* The password field is required<br />&nbsp;&nbsp;-Please fill in this field to continue'); $('#Password__error').show(); validated = false } else if (pass.length < RuleOutput('min', rule)) { $('#Password__error_image').attr('title', '* The minimum password length is invalid<br />&nbsp;&nbsp;-Please supply a password length larger than ' + RuleOutput('min', rule) + ' characters'); $('#Password__error').show(); validated = false } else if (pass.length > RuleOutput('max', rule)) { $('#Password__error_image').attr('title', '* The maximum password length is invalid<br />&nbsp;&nbsp;-Please supply a password length less than ' + RuleOutput('max', rule) + ' characters'); $('#Password__error').show(); validated = false } var conf = $('#PasswordConfirm_TextBox1').val(); watermark = $('#PasswordConfirm_TextBox1').attr('class').indexOf('watermark'); $('#PasswordConfirm__error_image').attr('title', ''); $('#PasswordConfirm__error').hide(); if ((pass.length > 6 && pass.length < 12) && conf.length == 0 || watermark > 1) { $('#PasswordConfirm__error_image').attr('title', '* The confirmation field is required<br />&nbsp;&nbsp;-Please fill in this field to continue'); $('#PasswordConfirm__error').show(); validated = false } else if (pass != conf) { $('#PasswordConfirm__error_image').attr('title', '* The password does not match the confirmation<br />&nbsp;&nbsp;-Please correct the confirmation field to continue'); $('#PasswordConfirm__error').show(); validated = false } return validated } function ValidateSignOn() { var validated = true; var email = $('#SignOnEmail_TextBox1').val(); var watermark = $('#SignOnEmail_TextBox1').attr('class').indexOf('watermark'); var regex = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; $('#SignOnEmail__error_image').attr('title', ''); $('#SignOnEmail__error').hide(); if (email.length == 0 || watermark > 1) { $('#SignOnEmail__error_image').attr('title', '* The email address field is required.<br />&nbsp;&nbsp;&nbsp;-Please fill in this field to continue'); $('#SignOnEmail__error').show(); validated = false } else if (!regex.test(email)) { $('#SignOnEmail__error_image').attr('title', '* The email address supplied does not match a valid mailbox expresion.<br />&nbsp;&nbsp;&nbsp;-Please correct to continue'); $('#SignOnEmail__error').show(); validated = false } var pass = $('#SignOnPassword_TextBox1').val(); var rule = $('#SignOnPassword_TextBox1').attr('class'); var watermark = rule.indexOf('watermark'); $('#SignOnPassword__error_image').attr('title', ''); $('#SignOnPassword__error').hide(); if (pass.length == 0 || watermark > 1) { $('#SignOnPassword__error_image').attr('title', '* The password field is required<br />&nbsp;&nbsp;-Please fill in this field to continue'); $('#SignOnPassword__error').show(); validated = false } else if (pass.length < RuleOutput('min', rule)) { $('#SignOnPassword__error_image').attr('title', '* The minimum password length is invalid<br />&nbsp;&nbsp;-Please supply a password length larger than ' + RuleOutput('min', rule) + ' characters'); $('#SignOnPassword__error').show(); validated = false } else if (pass.length > RuleOutput('max', rule)) { $('#SignOnPassword__error_image').attr('title', '* The maximum password length is invalid<br />&nbsp;&nbsp;-Please supply a password length less than ' + RuleOutput('max', rule) + ' characters'); $('#SignOnPassword__error').show(); validated = false } return validated } function ValidateForgot() { var validated = true; var email = $('#ForgotEmail_TextBox1').val(); var watermark = $('#ForgotEmail_TextBox1').attr('class').indexOf('watermark'); var regex = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; $('#ForgotEmail__error_image').attr('title', ''); $('#ForgotEmail__error').hide(); if (email.length == 0 || watermark > 1) { $('#ForgotEmail__error_image').attr('title', '* The email address field is required.<br />&nbsp;&nbsp;&nbsp;-Please fill in this field to continue'); $('#ForgotEmail__error').show(); validated = false } else if (!regex.test(email)) { $('#ForgotEmail__error_image').attr('title', '* The email address supplied does not match a valid mailbox expresion.<br />&nbsp;&nbsp;&nbsp;-Please correct to continue'); $('#ForgotEmail__error').show(); validated = false } return validated } $(document).ready(function() { $('#EmailAddress_TextBox1').watermark('enter an email address'); $('#Username_TextBox1').watermark('enter a username'); $('#MobileNumber_TextBox1').watermark('55'); $('#MobileNumber_TextBox2').watermark('555'); $('#MobileNumber_TextBox3').watermark('5555'); $('#Password_TextBox1').watermark('enter a password'); $('#PasswordConfirm_TextBox1').watermark('confirm password'); $('#SignOnEmail_TextBox1').watermark('enter email address'); $('#SignOnPassword_TextBox1').watermark('enter password'); $('#ForgotEmail_TextBox1').watermark('enter email address'); $('#Username_TextBox1').blur(function() { var watermark = $('#Username_TextBox1').attr('class').indexOf('watermark'); if ($('#Username_TextBox1').val().length > 0 && watermark == -1) { $('#Username__error_image').attr('title', ''); $('#Username__error').hide(); $.ajax({ type: "POST", url: "demo_register_step1.aspx/CheckUsername", data: "{username:'" + $('#Username_TextBox1').val() + "'}", contentType: "application/json;charset=utf-8", dataType: "json", success: function(msg) { if (msg.d.success == "found") { $('#Username__error_image').attr('title', '* The username supplied already exists.<br />&nbsp;&nbsp;-Please choose another name to continue.'); $('#Username__error').show() } }, error: function(msg) { } }) } }); $('#MobileNumber_TextBox3').blur(function() { var mobile = $('#MobileNumber_TextBox1').val() + $('#MobileNumber_TextBox2').val() + $('#MobileNumber_TextBox3').val(); var watermark = $('#MobileNumber_TextBox3').attr('class').indexOf('watermark'); if (mobile.length > 0 && watermark == -1) { $('#MobileNumber__error_image').attr('title', ''); $('#MobileNumber__error').hide(); $.ajax({ type: "POST", url: "demo_register_step1.aspx/CheckMobileNumber", data: "{mobile:'" + mobile + "'}", contentType: "application/json;charset=utf-8", dataType: "json", success: function(msg) { if (msg.d.success == "found") { $('#MobileNumber__error_image').attr('title', '* The mobile number supplied already exists.<br />&nbsp;&nbsp;-Please supply a different number to continue.'); $('#MobileNumber__error').show() } }, error: function(msg) { } }) } }); $('#EmailAddress_TextBox1').blur(function() { var watermark = $('#EmailAddress_TextBox1').attr('class').indexOf('watermark'); if ($('#EmailAddress_TextBox1').val().length > 0 && watermark == -1) { $('#EmailAddress__error_image').attr('title', ''); $('#EmailAddress__error').hide(); $.ajax({ type: "POST", url: "demo_register_step1.aspx/CheckEmail", data: "{email:'" + $('#EmailAddress_TextBox1').val() + "'}", contentType: "application/json;charset=utf-8", dataType: "json", success: function(msg) { if (msg.d.success == "found") { $('#EmailAddress__error_image').attr('title', '* The email address supplied already exists.<br />&nbsp;&nbsp;-Please supply an alternative email address to continue.'); $('#EmailAddress__error').show() } }, error: function(msg) { } }) } }) });