Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    [onBlur]Errore solo con Internet explorer

    Ciao a tutti,
    ho scritto un piccolo script che funziona bene con firefox, ma IE non lo digerisce..ovvero si imballa il browser e non ne capisco il motivo.
    Lo script deve solo riscirvere una frase nel campo input in caso non fosse stato scritto nulla..

    Codice HTML con 3 input chiamati Field0,Field1,etc..

    <table width="380" border="0" cellspacing="0" cellpadding="0">

    <tr>
    <td width="280" class="TxtVerdana8PtGrigio">01)[img]../../images/space.gif[/img]
    <input name="Field0" type="text" class="FrmVerdana8PtGrigio" id="Field0" value="&lt;Inserisci Campo1&gt;" size="30" onFocus="CleanField(this,0,1)" onBlur="CleanField(this,1,1)"></td>
    <td width="100" height="22" align="center" class="TxtVerdana8PtGrigio"><table width="100" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="25" align="center">SI</td>
    <td width="25" align="center"><input name="Required0" type="radio" value="1" ></td>
    <td width="25" align="center">NO</td>
    <td width="25" align="center"><input name="Required0" type="radio" value="0" checked></td>
    </tr>
    </table></td>
    </tr>
    </table>
    <table width="380" border="0" cellspacing="0" cellpadding="0">

    <tr>
    <td>[img]../../images/space.gif[/img]</td>
    </tr>
    </table>
    <table width="380" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="280" class="TxtVerdana8PtGrigio">02)[img]../../images/space.gif[/img]
    <input name="Field1" type="text" class="FrmVerdana8PtGrigio" id="Field1" value="&lt;Inserisci Campo2&gt;" size="30" onFocus="CleanField(this,0,2)" onBlur="CleanField(this,1,2)"></td>
    <td width="100" height="22" align="center" class="TxtVerdana8PtGrigio"><table width="100" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="25" align="center">SI</td>
    <td width="25" align="center"><input name="Required1" type="radio" value="1" ></td>
    <td width="25" align="center">NO</td>
    <td width="25" align="center"><input name="Required1" type="radio" value="0" checked></td>

    </tr>
    </table></td>
    </tr>
    </table>
    <table width="380" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td>[img]../../images/space.gif[/img]</td>
    </tr>
    </table>
    <table width="380" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="280" class="TxtVerdana8PtGrigio">03)[img]../../images/space.gif[/img]
    <input name="Field2" type="text" class="FrmVerdana8PtGrigio" id="Field2" value="&lt;Inserisci Campo3&gt;" size="30" onFocus="CleanField(this,0,3)" onBlur="CleanField(this,1,3)"></td>
    <td width="100" height="22" align="center" class="TxtVerdana8PtGrigio"><table width="100" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="25" align="center">SI</td>

    <td width="25" align="center"><input name="Required2" type="radio" value="1" ></td>
    <td width="25" align="center">NO</td>
    <td width="25" align="center"><input name="Required2" type="radio" value="0" checked></td>
    </tr>
    </table></td>
    </tr>
    </table>
    ogni campo input ha di default scritto <Inserisci Campon> (n=numero del campo). I metodi onblur e onfocus richiamano questo script

    codice:
    function CleanField(Box,w,n)
    	{
    	/*
    	Box = oggetto input da verificare
    	w = 0 On focus
    	w = 1 on blur (devo verificare che se č vuoto riscirvio <inserisci CampoXXX>
    	n = numero del campo che si sta lavorando
    	*/
    	if(w==0)
    		{
    		var reg = new RegExp(/^<Inserisci Campo+[0-9]{1,}>/);
    		if(reg.exec(Box.value)==Box.value)
    			{
    			Box.value="";
    			Box.focus();
    			}			
    		}
    	if(w==1)
    		{
    		if(Box.value=="")
    			{
    			Box.value="<Inserisci Campo" + n + ">";
    			Box.focus();
    			}			
    		}	
    	}
    il problema č...se metto il focus sul primo campo e poi clicco sul secondo..IE si blocca..invece su firefox nessun problema..ho anche testato su altri pc e continua a esserci il problema..quale č la compatibilitā che non č digerita da IE?

  2. #2

  3. #3

  4. #4
    risolto.

    č un buco di IE che non ha delle prioritā sul focus...ovvero la funzione mette il il focus sul campo non compilato..solo che lo fā qaundo l'utente ha messo il focus su un campo differente, quindi IE non capisce a chi dare la prioritā e da il focus a tutti e due i campi e vā in loop.


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.