Forum Moderators: open

Message Too Old, No Replies

validation need help to add radio support

validation need help to add radio support

         

CrazyBigGaz

12:27 pm on May 9, 2011 (gmt 0)

10+ Year Member



Hi,

I am using a script called osDate and I am trying to modify the sign up form to suit my setup.

So far I have the below, but I would like to check a set of radio buttons, but not sure, how to add it into the current code.


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>

CrazyBigGaz

2:30 pm on May 9, 2011 (gmt 0)

10+ Year Member



Found an answer


if ((form.fruit[0].checked == false) && (form.fruit[1].checked == false)) {
ErrorCount++;
ErrorMsg[ErrorCount]="Pick a fruit.";
}