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

    [js] funzione per input data

    Ciao ho creato un funzione js che precompila una text inserendo gli /

    codice:
    Funzione js
    
    <!--
    	function AutoCompleteDate_DDMMAAAA(obj)
    	{
    		// Check if the key is a number
    		var sKeyPressed;
    		sKeyPressed = new String(event.keyCode);
    		if (event.keyCode < 48 || event.keyCode > 57)
    		{
    			// don't insert last non-numeric character
    			event.keyCode = 0;
    		}
    		else
    		{
    			if (obj.value.length == 2)
    			{
    				obj.value += "/";
    			}
    			else if (obj.value.length == 5)
    			{
    				obj.value += "/";
    			}
    			else if (obj.value.length > 9)
    			{
    			var selText = (document.all) ? document.selection.createRange().text : document.getSelection();
    				if( selText.length == 0 )
    				{
    					// make sure the field doesn't exceed the maximum length
    					event.keyCode = 0;
    				}
    			}
    		}
    	}
    // -->
    
    Parte HTML
    
    <script language="JavaScript" type="text/JavaScript" src="../SCRIPT/funzioni.js"></script>
    ... ...
    <form name="Info" method="post" action="registra.asp">
    ... ...
    <input name="data" type="text" size="20" onKeyPress="AutoCompleteDate_DDMMAAAA(this);">
    Mi dice errore necessario oggetto, ma con this non capisce???

  2. #2
    Sono un idiota, avevo chiamato il js con un altro nome, mamma mia che co.....ne!!



    Scusate..

  3. #3

    script su firefox

    scusa il disturbo, ho utilizzato il codice js che riporti. E' corretto se dico che su firefox non funziona?
    Hai qualche soluzione?
    grazie

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.