Jump to content


Necho's Content

There have been 1 items by Necho (Search limited from 27/04/2023)


Ordernar por                Order  

#1020243 Javascript Versão Ie

Posted by Necho on 27/06/2013, 21:28 in Javascript / DOM / AJAX / ECMAScript

Boa Noite Galera blz?!

Seguinte, estou precisando fazer uma validação dinâmica de campos obrigatórios, até achei na internet esse código que funciona que seria esse:

<html>
<head>
<script>
function ValidarObrigatoriedade(form)
{
alert("s");
for (i=0;i<form.length;i++){
alert(form[i].obrigatorio);
var obg = form[i].obrigatorio;
if (obg==1){
if (form[i].value == ""){
var nome = form[i].name;
alert("O campo " + nome + " obrigatório.")
form[i].focus();
return false
}
}
}
return true
}
</script>
</head>
<body>

<br>
<form name="frm1" action="" onsubmit="ValidarObrigatoriedade(this)">
<input type="text" obrigatorio="1"  name="fname">
<input type="submit" value="Submit">
</form>

</body>
</html>

No entanto só funciona para o IE 7, 8 e 9, porém o IE 10 e o Chorme não funciona, pois a propriedade obrigatorio não acha e dá o erro undefined ..


Vocês poderiam me ajudar?

Grato!




IPB Skin By Virteq