Validation Category

radio button

In: Validation

function valbutton(thisform) {
// place any other field validations that you require here
// validate myradiobuttons
myOption = -1;
for (i=thisform.myradiobutton.length-1; i > -1; i–) {
if (thisform.myradiobutton[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert(”You must select a radio button”);
return false;
}
alert(”You selected button number ” + myOption
+ ” which has a value of ”
+ thisform.myradiobutton[myOption].value);
// place any [...]

numbers only

In: Validation

function checknumber(){
var x=document.checknum.pnum.value
var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(x))
testresult=true
else{
alert(”Please input a valid number!”)
testresult=false
}
return (testresult)
}

confirmation box

In: Validation

var answer = confirm(”You have chosen “+document.adtext.keyword.value+” as the keyword. Keyword is not changeable after the form submittion. \n Do you wish to confirm your booking?”)
if (answer){
}
else
{
return false;
}

character count

In: Validation

function countit(what){
formcontent=document.form.keyword.value
document.form.char.value=formcontent.length
}

gerenal validation

In: Validation

function validate_form()
{
valid=true;
}
<form action=”<?php echo $me ?>” method=”post” name=”form” enctype=’multipart/form-data’ onSubmit=”return validate_form()” >