Visualizzazione dei risultati da 1 a 10 su 11

Hybrid View

  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2013
    Messaggi
    49
    in attesa di capire se esiste la possibilità di fare la stessa cosa anche su FF, il workaround di cui parlavo era qualcosa del genere:

    codice:
    $('#idTextbox').keyup(function(){
         textValue = $(this).val()
         textLength = textValue.length;
         lastChar = textValue.substr(textLength-1,textLength);
         if(lastChar=='.')
              $(this).val(textValue.substr(0,textLength-1) + ",");
     });

  2. #2
    Quote Originariamente inviata da widoz83 Visualizza il messaggio
    in attesa di capire se esiste la possibilità di fare la stessa cosa anche su FF, il workaround di cui parlavo era qualcosa del genere:

    codice:
    $('#idTextbox').keyup(function(){
         textValue = $(this).val()
         textLength = textValue.length;
         lastChar = textValue.substr(textLength-1,textLength);
         if(lastChar=='.')
              $(this).val(textValue.substr(0,textLength-1) + ",");
     });
    grazie per il codice, ma in realtà il mio codice è estratto da uno più ampio questo:

    codice:
    function solo_numeri(evt, flag_virgola,numero_europeo)
    {
    // flag virgola true prevede l'inserimento di numeri decimali
    // numero europeo se true controlla che venga inserita la virgola se false permette di inserire il punto
    flag_virgola=typeof flag_virgola=='undefined'?false:flag_virgola;
    numero_europeo=typeof numero_europeo=='undefined'?true:numero_europeo;
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
    //alert (flag_virgola);
      if (flag_virgola==false){//solo numeri interi
        if (charCode> 31 && (charCode < 48 || charCode> 57)) {
        //alert("Puoi inserire solo numeri!");
        return false;
        }
      }
      if (flag_virgola==true){//solo numeri interi e virgola
      //carattere 44 è la virgola, il 46 è il punto
      char_virgola=numero_europeo==true?44:46;
      
      //alert (evt.charCode);
      
      if (charCode==46) {//no ie
    
        if(evt.charCode) {
          return (evt.charCode=42);
        }
          else {//sì ie
          return (evt.keyCode=42);
          }
      }
        if (charCode> 31 && charCode!=char_virgola && (charCode < 48 || charCode> 57)) {    
        //alert("Puoi inserire solo numeri decimali!");
        return false;
        }
      }
    return true;
    }
    che non fa riferimento ad uno specifico campo e nemmeno a jquery per cui preferirei evitare tutto ciò

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 © 2026 vBulletin Solutions, Inc. All rights reserved.