Con esto podremos validar una forma en Javascript lo pongo de forma rapida, despues le pongo mas formato y explicacion, disculpen las molestias
function validate(nombreForma) {
var theMessage = "Please complete the following:\n-----------------------------------\n";
var noErrors = theMessage
// No vacio
if (document.nombreForma.name.value=="") {
theMessage = theMessage + "\n --> Your name";
}
// Validar un correo electronico
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.form1.email.value)){
theMessage = theMessage + "\n --> Enter a valid e-mail address";
}
// Entrada de cierta cantidad de letras
var lengthCheck = document.nombreForma.code.value
if (lengthCheck.length < 4) {
theMessage = theMessage + "\n --> Enter 4 character code";
}
// radio button seleccionado
var radioCheck = false;
for (i = 0; i < document.nombreForma.gender.length; i++) {
if (document.nombreForma.gender[i].checked)
radioCheck = true; }
if (!radioCheck) {
theMessage = theMessage + "\n --> Choose your gender";
}
// Al menos un check box
var multiCheckbox = false;
for (i = 0; i < document.nombreForma.session.length; i++) {
if (document.nombreForma.session[i].checked)
multiCheckbox = true; }
if (!multiCheckbox) {
theMessage = theMessage + "\n --> Choose which session(s)";
}
// Select List Usar
var listCheck = document.form1.location.selectedIndex;
if (document.nombreForma.location.options[listCheck].value=="none") {
theMessage = theMessage + "\n --> Choose a location";
}
// Checkbox Activado
var boxCheck = false;
if (document.nombreForma.confirm.checked) {
boxCheck = true; }
if (!boxCheck) {
theMessage = theMessage + "\n --> Agree to the terms";
}
// No hubo errores
if (theMessage == noErrors) {
return true;
} else {
// Errores encontrados
alert(theMessage);
return false;
}
}