Block insert into box

0

In the code I create two boxes, one patrimony and another serial:

<table border="0" align="center" height="100">
    <tr>
        <td>   
            <font face="arial" align="center" valign="middle" color="blue" size="-1">PATRIMÔNIO</font><br>
            <input type="text" name="tx_patr" id="id_patr" maxlength="12" size="12" style="font-size:11; color:Black;" onkeypress="return SomenteNumero(event);" onkeyup="Mascara(this,Patri);" value="">
            <input type="button" onClick="move_patr_seri(this.form.tx_patr,this.form.cb_Patr);limpa_patr();" value=">>">
            <br>
            <select multiple size="7" name="cb_Patr" style="width:300"></select>
            <br>
            <input type="button" align="center" valign="middle" onClick="tira(this.form.cb_Patr)" value="<<">
            <br>
        </td>
        <td align="center" valign="middle" width="15%">
        </td>
        <td>  
            <font face="arial" align="center" valign="middle" color="blue" size="-1">SERIAL</font><br>
            <input type="text" name="tx_seri" id="id_seri"  maxlength="15" size="15" style="font-size:11; color:Black;" onblur="evento(this)"  value="">
            <input type="button"  onClick="move_patr_seri(this.form.tx_seri,this.form.cb_Seri);limpa_seri();" value=">>">
            <br>
            <select multiple size="7" name="cb_Seri" style="width:300"></select>
            <br>
            <input type="button" align="center" valign="middle" onClick="tira(this.form.cb_Seri)" value="<<">
            <br>
        </td>
    </tr>
</table>  

I want to block an entry in a box if an informed amount (coming from a previous program) is reached. For example:   "Informed quantity = 3, so the user can only enter 3 patrimony and if you want 3 serial, if you want to insert 4 patrimony or serial it should be blocked."!

EXAMPLE AT JSF: Box example and insert JavaScript

The variables that are in the JSF

var w_Qtde_Peri = 3; -> Quantidade informada
var w_Cont_Qtde = 0;
     var  w_ver = 1;
     var v_patr = new Array (w_Qtde_Peri);  

are PHP , so it will not include in the box!

    
asked by anonymous 01.10.2014 / 15:31

1 answer

1

I was able to get an answer to my problem!

In case to block, I just need to add this snippet:

 if((Destino.name == "cb_Seri") && (Destino.options.length == w_cont))
    { return false;} 
 if((Destino.name == "cb_Patr") && (Destino.options.length == w_cont))
    { return false;} 

Where w_cont receives the amount entered, thus not allowing the user to enter more than the total amount in the box!

    
01.10.2014 / 16:40