Visualizzazione dei risultati da 1 a 9 su 9
  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2001
    Messaggi
    184

    * # un pasticcio perfetto!

    Ho questa funzione js

    function ControllaValore(frm, cmp, valore, campoinput){
    var strTutteCau = document.forms[frm].elements[cmp].value;
    var txtCampoInp = document.forms[frm].elements[campoinput];
    var lRitorno = true;
    if(valore.lenght != 0 && valore != \"\" && valore != \" \" && valore != \" \"){
    valore = '#' + valore + '#';
    if(strTutteCau.search(valore) != -1){lRitorno = true;}
    else{
    txtCampoInp.value = \"\";
    alert(\"Codice causale Inesistente.\");
    txtCampoInp.focus();
    lRitorno = false;
    }
    }
    return lRitorno;
    }

    e in un form mi scrivo con il php una variabile nascosta così
    echo "<input type=\"Hidden\" name=\"TuttiVal\" value=\"$ListaVal\">";

    Ovviamente i valori sono fra #, quindi #valore#.

    Chiamo su OnBlur il controllo e funziona, ma se l'ultimo carattere è l'* non c'è verso!!!

    Come e dove sbaglio ?

    Premesso sto utilizzando la codifica utf8, prima con l'ISO funzionava, ma per esigenze di server, è stato obbligatoriamente cambiato.

    Suggerimenti ?

  2. #2
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Vediamo la pagina pubblica online che come hai scritto la funzione js non si capisce cosa vuoi fare e forse ci sono errori
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  3. #3
    Utente di HTML.it
    Registrato dal
    Nov 2001
    Messaggi
    184

    non è ancora online

    function ControllaValore(frm, cmp, valore, campoinput){
    var strTutteCau = document.forms[frm].elements[cmp].value;
    var txtCampoInp = document.forms[frm].elements[campoinput];
    var lRitorno = true;
    if(valore.lenght != 0 && valore != "" && valore != " " && valore != " "){
    valore = '#' + valore + '#';
    if(strTutteCau.search(valore) != -1){lRitorno = true;}
    else{
    txtCampoInp.value = "";
    alert("Codice causale Inesistente.");
    txtCampoInp.focus();
    lRitorno = false;
    }
    }
    return lRitorno;
    }

  4. #4
    Moderatore di JavaScript L'avatar di br1
    Registrato dal
    Jul 1999
    Messaggi
    19,998
    Sei sicuro che il contenuto di valore sia una RegExpr valida dato che la usi come tale?
    Il guaio per i poveri computers e' che sono gli uomini a comandarli.

    Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
    Consultate la discussione in rilievo: script / discussioni utili
    Usate la funzione di Ricerca del Forum

  5. #5
    Utente di HTML.it
    Registrato dal
    Nov 2001
    Messaggi
    184
    In che senso ?

  6. #6
    Utente di HTML.it
    Registrato dal
    Nov 2001
    Messaggi
    184
    O per essere più precisi, perchè in ISO anche se non fosse regolare funzionava, in UTF no ?
    Ma soprattutto come potrei gestirla diversamente la cosa ?

  7. #7
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Almeno posta tutta la pagina html (no codice php) per provare a simularla in locale
    Cambiando la codifica modifichi i caratteri
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  8. #8
    Utente di HTML.it
    Registrato dal
    Nov 2001
    Messaggi
    184
    <html>
    <head>
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate"/>
    <meta http-equiv="Expires" content="Mon, 26 Jul 1997 05:00:00 GMT">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <SCRIPT LANGUAGE = "Javascript" charset="UTF-8">
    function WinPers(url,name,w,h){
    lt = (screen.width - w)/2;
    tp = (screen.height - h)/2;

    popupWin = window.open(url,name,'left='+lt+', top='+tp+', scrollbars=yes,titlebar=yes, status=yes , resizable=yes, width='+w+',height = '+h)
    }


    function checkNum(name){

    var cont = document.inserimento.name.value;

    var len = cont.length;

    var count = 0;

    var notNumber = 0;

    var valore = '';


    for( count=0; count < len; count++ ){

    switch (count.charAt( count)){

    case 0 : valore = valore + cont.charAt( count );

    case 1 : valore = valore + cont.charAt( count );

    case 2 : valore = valore + cont.charAt( count );

    case 3 : valore = valore + cont.charAt( count );

    case 4 : valore = valore + cont.charAt( count );

    case 5 : valore = valore + cont.charAt( count );

    case 6 : valore = valore + cont.charAt( count );

    case 7 : valore = valore + cont.charAt( count );

    case 8 : valore = valore + cont.charAt( count );

    case 9 : valore = valore + cont.charAt( count );

    case '.' : valore = valore + cont.charAt( count );

    default: notNumber = 1;break;

    }

    }


    if(notNumber == 1){

    window.alert('Sono possibili solo numeri in questo campo');

    window.inserimento.name.value = valore;

    }else{window.inserimento.name.value = cont;}



    }


    function ControllaValore(frm, cmp, valore, campoinput){
    var strTutteCau = document.forms[frm].elements[cmp].value;
    var txtCampoInp = document.forms[frm].elements[campoinput];
    var lRitorno = true;
    if(valore.lenght != 0 && valore != "" && valore != " " && valore != " "){
    valore = '#' + valore + '#';
    if(strTutteCau.search(valore) != -1){lRitorno = true;}
    else{
    txtCampoInp.value = "";
    alert("Codice causale Inesistente.");
    txtCampoInp.focus();
    lRitorno = false;
    }
    }
    return lRitorno;
    }

    function ControllaCdc(frm, cmp, valore, campoinput){
    var strTutteCau = document.forms[frm].elements[cmp].value;
    var txtCampoInp = document.forms[frm].elements[campoinput];
    var lRitorno = true;
    if (valore.lenght != 0 && valore != "" && valore != " " && valore != " "){
    valore = '#' + valore + '#';
    if (strTutteCau.search(valore) != -1){lRitorno = true;}
    else{
    txtCampoInp.value = "";
    alert("Centro di costo Inesistente.");
    txtCampoInp.focus();
    lRitorno = false;
    }
    }
    return lRitorno;
    }

    function onlynum(e, h){
    if (h == 0){ Min = 46;}else{Min = 48;}
    if (e.which){
    if(e.which!=Min && e.which!=13 && e.which!=8 && (e.which<48 || e.which>57))
    return false;
    }else if(e.keyCode){
    if(e.keyCode!=Min && e.keyCode!=13 && e.keyCode!=8 && (e.keyCode<48 || e.keyCode>57))
    return false;
    }
    return true;
    }

    function is_importo(importo,importo_min,importo_max,campo,f orm){
    var miaform = form.name;
    if(importo == "" && importo_min == 0){return true;}
    if(isNaN(importo)){
    alert('Importo non valido!');
    document.forms[miaform].elements[campo].value='';
    document.forms[miaform].elements[campo].focus();
    return false;
    }
    if(importo_min=="" || importo_max==""){
    if(importo<0){
    alert('Valore importo non valido!');
    document.forms[miaform].elements[campo].value='';
    document.forms[miaform].elements[campo].focus();
    return false;
    }else{return true;}
    }else{
    if(isNaN(importo_min) && isNaN(importo_max)){
    return false;
    }else{
    if(importo>=importo_min && importo<=importo_max){
    return true;
    }else{
    alert('Valore importo non valido!');
    document.forms[miaform].elements[campo].value='';
    document.forms[miaform].elements[campo].focus();
    return false;
    }
    }
    }
    }

    function chk_giornomese(gg,mese,campo,form){
    var miaform = form.name;
    if(gg == ""){return true;}

    if(isNaN(gg)){
    alert("Giorno non valido!");
    document.forms[miaform].elements[campo].value='';
    document.forms[miaform].elements[campo].focus();
    return false;
    }

    switch (mese){
    case 2:
    limit = 28;
    break;
    case 4:
    limit = 30;
    break;
    case 6:
    limit = 30;
    break;
    case 9:
    limit = 30;
    break;
    case 11:
    limit = 30;
    break;
    default:
    limit = 31;
    break;
    }

    if(gg<0 || gg>limit){
    alert("Giorno non valido!");
    document.forms[miaform].elements[campo].value='';
    document.forms[miaform].elements[campo].focus();
    return false;
    } else {return true;}
    }

    </SCRIPT>



    <script language="javascript">

    var isNav=false
    if (parseInt(navigator.appVersion)>=4){
    if(navigator.appName == "Netscape"){
    window.captureEvents(Event.ONKEYPRESS);
    window.onkeypress = prova;
    isNav = true;
    }
    else
    document.onkeydown = prova;
    }

    var pos=null;
    var valF9=null;
    var prefisso='txt';
    var prefTot='TotCartGio';

    function WinDown(url,name,w,h)
    {
    lt = (screen.width - w)/2;
    tp = (screen.height - h)/2 + 100;

    popupWin = window.open(url,name,'left='+lt+', top='+tp+', scrollbars=yes,titlebar=yes, status=yes , resizable=yes, width='+w+',height = '+h)
    }

    function Azione34() {
    if (num < 99500){
    if(num<434+1) num=num+31
    else num=num+31-465
    }
    else
    {
    if(num<99686) num=num+62
    else num=num+62-248
    }
    }

    function Azione33() {
    if (num < 99500){
    if(num>31)num=num-31
    else num=num-31+465
    }
    else
    {
    if(num>=562)num=num-62
    else num=num-62+248
    }
    }

    function Azione120() {
    if ((valF9 == 1) || (valF9 == 3))
    {
    WinPers('causali.php?valF9='+valF9+'&Form=inserime nto&Msg='+pos+'&dati=demo&FlgInt=&FlgOrder=0','cau s',450,550)
    }

    if (valF9 == 20)
    {
    WinPers('centricosto.php?valF9='+valF9+'&TabCdc=cl _demo_201203z&Azi=028&Form=inserimento&Msg='+pos+' &dati=demo&FlgInt=&FlgOrder=0','caus',450,550)
    }

    }

    function Azione121() {
    document.inserimento.submit();
    }

    function Azione113() {
    WinDown('eventi.php?&mat=0006&lm=1&azi=028&uni=01& dati=demo&anno=2012&mese=03&user=cl_demo','eventi' ,900,460);
    }

    function Azione123() {

    var tipo = document.forms[0].Tipo;
    for(var i=0; i<tipo.length; i++)
    {
    if (tipo[i].checked)
    {
    if (i == 0)
    {
    WinDown('f4.php?Tipo=Presenze' + '&dati=demo&Mese=03&Anno=2012&azi=028&uni=01&mat=0 006&lm=1&flg4=0&User=cl_demo&FlgOrder=0','F4',650, 450);
    }
    else
    {
    WinDown('f4.php?Tipo=Straordinario' + '&dati=demo&Mese=03&Anno=2012&azi=028&uni=01&mat=0 006&lm=1&flg4=0&User=cl_demo&FlgOrder=0','F4',650, 450);
    }
    break;
    }
    }
    }

    function Azione118(F7, St) {
    if (F7 != 'N')
    {
    document.inserimento.FnClic.value='F7';
    }

    Sw = Azione121();

    }

    function Azione119(F8, St) {
    if (F8 != 'N')
    {
    document.inserimento.FnClic.value='F8';
    }

    Sw = Azione121();

    }

    function prova(e)
    {
    if(isNav){ Evento = e.keyCode; }
    else{ Evento = window.event.keyCode;}

    if(pos!=null)
    {
    num = parseInt(pos.substr(prefisso.length));
    switch (Evento)
    {
    case 33:
    Azione33();
    break;
    case 34:
    Azione34();
    break;
    case 113:
    /* document.forms[0].FlgF2.value="S"; */
    /* Azione121(); */
    break;
    case 120:
    Azione120();
    break;
    case 121:
    Azione121();
    break;
    case 123:
    /* document.forms[0].FlgF12.value="S"; */
    /* Azione121(); */
    break;
    case 118:
    /* Azione118('N', 'N'); */
    break;
    case 119:
    /* Azione119('', 'N'); */
    break;
    }

    if (num > 0)
    {
    pos = prefisso+num;
    document.forms[0].elements[pos].focus();

    }
    }
    else {
    switch (Evento)
    {
    case 121:
    Azione121();
    break;
    case 118:
    /* Azione118('N', 'N'); */
    break;
    case 119:
    /* Azione119('', 'N'); */
    break;
    }
    }
    }


    ....
    </script>

    <style>
    A:link, A:visited { text-decoration: none }
    input {font: 8pt verdana; font-weight: none; text-decoration: none; border: 0 solid #FFFFFF;}
    </style>

    <Title></Title>
    </head>
    <body bgcolor = "#99CCFF" link = "#0000FF" vlink = "#0000FF" alink = "#0000FF" OnLoad = "VerUnLoad=0; "document.inserimento.txt1.focus();
    >


    <form action="ins_pre/regpre.php" method="post" NAME = "inserimento" OnSubmit = "return false"><INPUT TYPE = "Hidden" Name = "FlgOrder" Value = "0"><INPUT TYPE = "Hidden" Name = "dati" Value = "demo"><INPUT TYPE = "Hidden" Name = "FnClic" Value = "1"><input type="Hidden" name="TutteLeCau" value="#38##62##A##AA##AE##AG##AL##AP##AR##AS##BP# #CA##CD##CE##CF##CG##CI##CM##CS##DS##EX##F##FE##FG ##FL##FN##FO##FP##FS##FX##GM##GS##I##I1##IC##IG##L ##LF##M##MA##MF##MI##MN##MS##MT##MU##OV##P##PA##PE ##PF##PG##PI##PL##PN##PP##PR##PS##PU##R##RC##RE##R F##RS##RV##RX##S##SC##SL##SP##ST##T##TD##UT##VM##X ##AF##CO##G1##LS##MO##PH##RN##SF##SN##SR##SX##TF## TG##TN##TO##TR##A ##ff##AC##AD##AI##AM##F4##FR##I2##LU##M ##Ma##P ##RO##S ##SO##ca##i ##i1##i2##ic##ma##mi##F ##FC##Fs##I ##IT##L ##MB##NR##P1##P2##R ##RI##SG##T ##X ##XX##as##ci##cm##ds##pp##F1##F2##F3##FI#"><input type="Hidden" name="TuttiICdc" value="#IASS*##ICOM##IPROW#"><INPUT TYPE = "Hidden" Name = "OreMinuti" Value = "N"><table width = "100%" border = "0px" cellspacing = "0" cellpadding = "0" bgcolor = "#CEFFFF">

  9. #9
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Come non detto, se non metti una pagina online dubito che troverari aiuti, comunque auguri.
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

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.