Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    833

    togliere blanks da campo di input

    Ciao. come si fa a togliere i caratteri blanks di un campo, mi spiego meglio ho un campo

    print 'Caso chiuso. . . . . . . . . . . . <input type="text" size="1" maxlength="1" name="customerSRVCAS" value="'.$customerSRVCAS.'"/>
    ';

    e ho messo il controllo per l'obbligatorieta' del campo, pero' ho visto che se tolgo il valore
    (es. S) devo togliere anche dei blanks che sono presenti dopo il valore che c'era nel campo.

    Come posso fare per non fare vedere e gestrire i campi blanks?

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    833
    up

  3. #3
    Utente di HTML.it
    Registrato dal
    Nov 2001
    Messaggi
    525
    che intendi per blanks, gli spazi? In quel caso per togliere gli spazi all'inizio e alla fine della stringa usa

    $str_no_blank=trim($stringa)

    Se invece hai necessità di memorizzare solo valori concreti, qdi evitare che l'utente inserisca nel campo una serie di spazi bianchi:

    if ($str_no_blank == "")
    echo "l'utente non ha inserito un valore valido";

  4. #4
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    833
    Scusa la mia ignoranza ma come lo devo usare il codice $str_no_blank=trim($stringa)
    ti posto come visualizzo i campi, mi puoi fare un esempio di come usarlo?
    Deve essere su tutti i campi di input questo codice.

    Posto i campi a cui applicare il codice che mi hai postato

    $sql = "select *
    from ACSSI_DAT.srvrq00f
    where srvcli = '".$customerSRVCLI."'
    and srvnum = '".$customerSRVNUM."' ";


    /* Esecuzione diretta dello stament SQL */
    $stmt = db2_exec($dbh, $sql, array('cursor' => DB2_SCROLLABLE));

    /* Salvataggio dei dati estratti in un array */
    $row = db2_fetch_array($stmt);

    $str_no_blank=trim($stringa)


    /* Ciclo di lettura dei dati estratti e stampa */
    if (!$row=="") {
    $customerSRVSRN = $row[11];
    $customerSRVMOD = $row[12];
    $customerSRVNSP = $row[13];
    $customerSRVPRO = $row[9];
    $customerSRVVER = $row[10];
    $customerSRVPMO = $row[47];
    $customerSRVVRM = $row[48];
    $customerSRVBLD = $row[42];
    $customerSRVREL = $row[40];
    $customerSRVASP = $row[41];
    $customerSRVDAT = $row[18];
    $customerSRVORA = $row[19];
    $customerSRVPER = $row[17];
    $customerSRVMOT = $row[20];
    $customerSRVCAS = $row[21];
    $customerSRVUSR = $row[23];
    $customerSRVVIS = $row[16];
    $customerSRVPRR = $row[24];
    $customerSRVVRR = $row[25];
    $customerSRVSOL = $row[22];
    $customerSRVDUR = $row[38];
    $customerSRVWEK = $row[39];
    $customerSRVPCH = $row[45];
    $customerSRVVAS = $row[46];

    }
    /* Il controllo viene passato ad un altro script PHP per l'aggiornamento dati cliente */
    ?>


    <table border="0" width="950">
    <tr>
    <td height="55"></td>

    </tr>
    <tr>
    <td>
    <div class="box" align="left">


    <div class="box" align="left">
    <table border="0" width="990">
    <tr>
    <td width="900px">
    <?php
    print '<form name="action" onsubmit="return checkForm();" action="db2_update3.php?customerSRVCLI=' . $customerSRVCLI .'&customerSRVNUM=' . $customerSRVNUM . '" method="POST">';



    Print 'Server cliente. . . . . . . . . . .'.$customerSRVCLI.' '.$customerSRVNUM.'
    ';
    Print 'S/N server/Mod./Sist-Part. '.$customerSRVSRN.' '.$customerSRVMOD.' '.$customerSRVNSP.'
    ';
    Print 'Prodotto/Versione. . . . . . . '.$customerSRVPRO.' '.$customerSRVVER.'
    ';
    print 'Modulo/versione. . . . . . . . . <input type="text" size="10" maxlength="10" onkeyup=verificacaratteri(this); name="customerSRVPMO" value="'.$customerSRVPMO.' "/><input type="text" size="1" onkeyup=verificacaratteri(this); maxlength="3" name="customerSRVVRM" value="'.$customerSRVVRM.'"/>
    ';
    print 'Build/Service: rls./pack . . . <input type="text" size="1" onkeyup=verificanumeri(this); maxlength="3" name="customerSRVBLD" value="'.$customerSRVBLD.'" /><input type="text" size="1" onkeyup=verificanumeri(this); maxlength="2" name="customerSRVREL" value="'.$customerSRVREL.'"/><input type="text" onkeyup=verificanumeri(this); size="1" maxlength="2 " name="customerSRVASP" value="'.$customerSRVASP.'"/>
    ';
    print 'Richiesta effettuata il. . . . . <input type="text" size="10" maxlength="10" name="customerSRVDAT" value="'.$customerSRVDAT.'"onkeyup="verificadata(t his);"/> ora <input type="text" size="8" onkeyup=verificadata(this); maxlength="8" name="customerSRVORA" value="'.$customerSRVORA.'" />
    ';
    print 'Richiesta effettuata da. . . .<input type="text" size="35" maxlength="35" onkeyup=verificacaratteri(this); name="customerSRVPER" value="'.$customerSRVPER.'" />
    ';

    print 'Motivo della chiamata:
    ';

    /*print '<textarea name="customerSRVMOT" rows="3" cols="100" onchange="conta(this.form);">'.$customerSRVMOT.' </textarea>
    ';
    */
    print '<textarea name="customerSRVMOT" rows="3" cols="100" onkeyup=conta(this.form);verificacaratteri(this);> '.$customerSRVMOT.' </textarea> ';

    print '

    ';


    print 'Caso chiuso. . . . . . . . . . . . <input type="text" size="1" onkeyup=verificaflag(this); maxlength="1" name="customerSRVCAS" value="'.$customerSRVCAS.'"/>Durata: gestione <input type="text" size="2" maxlength="4" onkeyup=verificanumeri(this); name="customerSRVDUR" value="'.$customerSRVDUR.'"/>Week <input type="text" onkeyup=verificanumeri(this); size="2" maxlength="4" name="customerSRVWEK" value="'.$customerSRVWEK.'"/>
    ';

    print 'Erogatore servizio. . . . . . . <input type="text" size="6" onkeyup=verificacaratteri(this); maxlength="6" name="customerSRVUSR" value="'.$customerSRVUSR.'"/>
    ';
    print 'Service: codice vision. . . . <input type="text" size="10" onkeyup=verificacaratteri(this); maxlength="10" name="customerSRVVIS" value="'.$customerSRVVIS.'"/>
    ';
    print 'Prodotto/Vrs. richiesti. . . . <input type="text" size="10" maxlength="10" onkeyup=verificacaratteri(this); name="customerSRVPRR" value="'.$customerSRVPRR.'"/><input type="text" size="1" onkeyup=verificacaratteri(this); maxlength="3" name="customerSRVVRR" value="'.$customerSRVVRR.'"/>
    ';
    print 'Patch/Asp. . . . . . . . . . . . . . <input type="text" size="5" maxlength="5" onkeyup=verificacaratteri(this); name="customerSRVPCH" value="'.$customerSRVPCH.'"/><input type="text" size="4" maxlength="5" onkeyup=verificacaratteri(this); name="customerSRVVAS" value="'.$customerSRVVAS.'"/>
    ';

    print 'Soluzione:
    ';

    print '<textarea name="customerSRVSOL" rows="3" cols="100" name="customerSRVSOL" onkeyup=conta(this.form);verificacaratteri(this);> '.$customerSRVSOL.' </textarea> ';



    print '

    ';
    ?>

    </td> <td>

    <?php
    print '<input type="submit" name="action" value="Update" /></form>';
    print '<form action="db2_delete5.php?customerSRVCLI=' . $customerSRVCLI .'&customerSRVNUM=' . $customerSRVNUM . '" method="POST">';
    print '<input type="submit" name="action" value="Delete " /></form>';
    print '<form action="db2_update1.php" method="POST">';
    print '<input type="submit" name="action" value="Back " /></form>';
    print '<form action="db2_update4.php" method="POST">';
    print '<input type="submit" name="close" value="Close " /></form>';
    print '<form action="db2_update6.php" method="POST">';
    print '<input type="submit" name="New" value="New " /></form>';
    print '</form>';

    }

    ?>


    Ciao, grazie

  5. #5
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    833
    Ho provato a mettere il codice che mi hai detto cosi'

    print '<textarea name="customerSRVSOL" rows="3" cols="100" name="customerSRVSOL" $str_no_blank=trim($stringa) onkeyup=conta(this.form);verificacaratteri(this);> '.$customerSRVSOL.' </textarea> ';

    Solo che sembra togliere i blanks solo se faccio qualche opreazione dentro, esempio se cancello il valore presente nel campo.

    Pero' a me serve inizializarlo cosi', perche' se nel campo non c'e' il motivo, dovrebbe essere obbligatorio solo che siccome non ho modificato il campo il codice che mi hai postato non ha tolto i blanks e quindi riesco a aggiornare il record anche se non ho immesso il motivo.

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