function valida(form){

var elementos = form.elements; 
var controlea = 0;
var controleb = 0;

for(var i=0; i< elementos.length; i++){ 
if (elementos[i].getAttribute("id")=="ocr"){
if (elementos[i].checked == false){
alert('Caixa OCR deve ser marcada');
return false; 
}
}  

if (elementos[i].getAttribute("id")=="obrigatorio"){

if (elementos[i].value=="") {      
alert("O campo "+elementos[i].getAttribute("name")+ " é obrigatorio.");
return false;     
}

if (elementos[i].getAttribute("type")=="radio"){
controlea++;
if (elementos[i].checked == false){
controleb++;
}
}

if (elementos[i].getAttribute("name")=="email"){
if (elementos[i].value=="") {      
alert("O campo "+elementos[i].getAttribute("name")+ " é obrigatorio.");
return false;     
}
if (!(/^\w+([\-]?\w+)*@\w+([\-]?\w+)*(\.\w{2,3})+$/.test(elementos[i].value))){
alert("O campo "+elementos[i].getAttribute("name")+ " esta incorreto.")
return false;
}}
}}

if (controlea == controleb){
if (controlea >= 1){
alert("Selecione uma das opções");
return false;
}else{
return true; 
}
}else{  
return true; 
}

}

function somente_numero(campo){
var digits="0123456789"
var campo_temp 
for (var i=0;i<campo.value.length;i++){
campo_temp=campo.value.substring(i,i+1)    
if (digits.indexOf(campo_temp)==-1){
campo.value = campo.value.substring(0,i);
break;
}}}


