Forum Moderators: open
var alphanumeric_chars = "0123456789.+-_#,/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ()_";
var alphanum_chars = "0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var text_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz /'";
var full_chars = "0123456789.+-_#,/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz() _$+=;:?'";
<script type="text/javascript">
/* <![CDATA[ */
function validateme(form)
{
var tos_ok = form.accept_tos.checked;
ErrorCount=0;
ErrorMsg = new Array();
/* log details */
CheckFieldString("noblank",form.username,"Please enter the username.");
CheckFieldString("alphanum",form.username,"Only letters, numbers and underscores '_' are allowed in the username.");
CheckFieldString("noblank",form.email,"Email must be specified.");
CheckFieldString("email",form.email,"Email address is not valid.");
CheckFieldString("noblank",form.firstname,"First Name must be specified.");
CheckFieldString("text",form.firstname,"Only letters are allowed in First Name.");
CheckFieldString("noblank",form.lastname,"Last Name must be specified.");
CheckFieldString("text",form.lastname,"Only letters are allowed in Last Name.");
CheckFieldString("noblank",form.address1,"Last Name must be specified.");
CheckFieldString("full",form.address1,"Only letters, numbers and underscores '_' are allowed in the password.");
CheckFieldString("full",form.address2,"Only letters, numbers and underscores '_' are allowed in the password.");
CheckFieldString("noblank",form.city,"Last Name must be specified.");
CheckFieldString("text",form.city,"Only letters are allowed in Last Name.");
if(form.username.value.length >= 5 && form.username.value.length <= 20){
if ( !isNaN(form.username.value.charAt(0)) ){
ErrorCount++;
ErrorMsg[ErrorCount] = "Username must start with a letter." ;
}
}else{
ErrorCount++;
ErrorMsg[ErrorCount] = "Number of characters in username should be between the specified range." ;
}
if (tos_ok != true) {
ErrorCount++;
ErrorMsg[ErrorCount]="Please read and accept the Terms of Service before registering";
}
/* concat all error messages into one string */
result="";
if( ErrorCount > 0)
{
result = "---- Following errors occured -----"+ String.fromCharCode(13)+ String.fromCharCode(10);
for( c in ErrorMsg)
result += ErrorMsg[c]+ String.fromCharCode(13)+ String.fromCharCode(10)+ String.fromCharCode(10);
alert(result);
return false;
}
return true;
}
/* ]]> */
</script>