function formhash(form, password) { // Create a new element input, this will be our hashed password field. var p = document.createElement("input"); // Add the new element to our form. form.appendChild(p); p.name = "p"; p.type = "hidden"; p.value = hex_sha512(password.value); // Make sure the plaintext password doesn't get sent. password.value = replacePW(password); // Finally submit the form. form.submit(); } function regformhash(form, uid, email, password, conf, validation) { // Check each field has a value if (uid.value == '' || email.value == '' || password.value == '' || conf.value == '' || validation.value == '') { // alert('You must provide all the requested details. Please try again'); return false; } // Check the email if (!checkemail(email.value)) { // alert("Email address is not valid"); return false; } // Check the username re = /^\w+$/; if(!re.test(form.username.value)) { alert("Username must contain only letters, numbers and underscores. Please try again"); form.username.focus(); return false; } // Check that the password is sufficiently long (min 6 chars) // The check is duplicated below, but this is included to give more // specific guidance to the user if (password.value.length < 6) { // alert('Passwords must be at least 6 characters long. Please try again'); form.password.focus(); return false; } // At least one number, one lowercase and one uppercase letter // At least six characters var re = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/; if (!re.test(password.value)) { // alert('Passwords must contain at least one number, one lowercase and one uppercase letter. Please try again'); return false; } // Check password and confirmation are the same if (password.value != conf.value) { // alert('Your password and confirmation do not match. Please try again'); form.password.focus(); return false; } // Create a new element input, this will be our hashed password field. var p = document.createElement("input"); // Add the new element to our form. form.appendChild(p); p.name = "p"; p.type = "hidden"; p.value = hex_sha512(password.value); // Make sure the plaintext password doesn't get sent. password.value = replacePW(password); conf.value = replacePW(password); // Finally submit the form. // form.submit(); return true; } function resetformhash(form, password, conf) { // Check each field has a value if (password.value == '' || conf.value == '') { // alert('You must provide all the requested details. Please try again'); return false; } // Check that the password is sufficiently long (min 6 chars) // The check is duplicated below, but this is included to give more // specific guidance to the user if (password.value.length < 6) { // alert('Passwords must be at least 6 characters long. Please try again'); form.password.focus(); return false; } // At least one number, one lowercase and one uppercase letter // At least six characters var re = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/; if (!re.test(password.value)) { // alert('Passwords must contain at least one number, one lowercase and one uppercase letter. Please try again'); return false; } // Check password and confirmation are the same if (password.value != conf.value) { // alert('Your password and confirmation do not match. Please try again'); form.password.focus(); return false; } // Create a new element input, this will be our hashed password field. var p = document.createElement("input"); // Add the new element to our form. form.appendChild(p); p.name = "p"; p.type = "hidden"; p.value = hex_sha512(password.value); // Make sure the plaintext password doesn't get sent. password.value = replacePW(password); conf.value = replacePW(password); // Finally submit the form. // form.submit(); return true; } function replacePW(password) { var str=password.value; var pLen=str.length; var dummy=""; var upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var lower = "abcdefghijklmnopqrstuvwxyz"; var numbers = "A0123456789"; var special = "$/@^%&*()!"; dummy += upper.charAt(Math.floor(Math.random() * upper.length)); dummy += lower.charAt(Math.floor(Math.random() * lower.length)); dummy += numbers.charAt(Math.floor(Math.random() * numbers.length)); dummy += special.charAt(Math.floor(Math.random() * special.length)); for( var i=0; i < n; i++ ) dummy += lower.charAt(Math.floor(Math.random() * lower.length)); return dummy; } function checkemail(str){ var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i if (filter.test(str)) testresults=true else{ // alert("Please input a valid email address!") testresults=false } return (testresults) } function verify_delete(form,type) { var recname=form.name.value; var message="Are you sure you want to delete record for " + recname + "?"; if (type=='product') { message="Are you sure you want to permanently delete record for " + recname + "?\n\n(To make unavailable, uncheck the top box in product page.)"; } if (confirm(message)) { form.action='delete_'+type+'.html'; form.submit() } else { return false; //will not submit the form } }