Ho scoperto un brutto inconveniente... funziona con più blocchi di input ma non con uno solo come in questo caso!!!

Perchè? Sto impazzendo!!!




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<script type="text/javascript">
<!--
function Control(){
var brands = document.modulo.elements['brands[]'];
for(var i=0; i<brands.length; i++) {
if (brands[i].value==""){
alert("Devi specificare la marca del prodotto.");
brands[i].focus();
return false;
}
}
var models = document.modulo.elements['models[]'];
for(var i=0; i<models.length; i++) {
if (models[i].value==""){
alert("Devi specificare il modello del prodotto.");
models[i].focus();
return false;
}
}
var short_descs = document.modulo.elements['short_descs[]'];
for(var i=0; i<short_descs.length; i++) {
if (short_descs[i].value==""){
alert("Devi inserire una breve descrizione del prodotto.");
short_descsi[i].focus();
return false;
}
}
var descriptions = document.modulo.elements['descriptions[]'];
for(var i=0; i<descriptions.length; i++) {
if (descriptions[i].value==""){
alert("Devi inserire la descrizione del prodotto.");
descriptions[i].focus();
return false;
}
}
var prices = document.modulo.elements['prices[]'];
for(var i=0; i<prices.length; i++) {
if (prices[i].value==""){
alert("Devi inserire il prezzo del prodotto.");
prices[i].focus();
return false;
}
if (!prices[i].value.match(/^(\d*?)(\,\d{2})?$/)) {
alert("Il prezzo del prodotto deve essere in uno dei seguentei formati: 10 o 10,00.");
prices.focus();
return false;
}
}
var discounts = document.modulo.elements['discounts[]'];
for(var i=0; i<discounts.length; i++) {
if (discounts[i].value!="" && !discounts[i].value.match(/^(\d*?)(\,\d{2})?$/)) {
alert("Lo sconto del prodotto deve essere in uno dei seguentei formati: 10 o 10,00.");
discounts.focus();
return false;
}
}

document.modulo.action = "edit.php?action=p_e";
document.modulo.submit();
}
//-->
</script>
</HEAD>
<BODY>

<FORM name="modulo" method="POST">



*****

<INPUT type="hidden" name="ids[]" value="12">
Marca*: <INPUT type="text" name="brands[]" maxlength="128" value="p">

Modello*: <INPUT type="text" name="models[]" maxlength="128" value="">

Descrizione breve*: <INPUT type="text" name="short_descs[]" maxlength="128" value="p">(Max 128 caratteri)

Descrizione*: <TEXTAREA name="descriptions[]" rows="4" cols="15"></TEXTAREA>

Prezzo*: <INPUT type="text" name="prices[]" value="0">

Sconto: <INPUT type="text" name="discounts[]" value="">

Immagine

Disponibilità: <INPUT type="text" name="availabilitys[]" value="100">

Categoria*: <SELECT name="categorias[]">
<OPTION value="8">giocattoli
<OPTION value="4">informatica
<OPTION selected value="3">telefonia
</SELECT>

*****</P>
<INPUT type="button" value="Conferma" onClick="Control()">
<INPUT type="reset" value="Annulla">
</FORM>

</BODY>
</HTML>