Salta al contenuto
  • CATEGORIES
  • La Community Connect.gt
  • Presentati alla Community
  • News Ufficiali da Connect.gt
  • Internet News
  • A Scuola Di
  • Digital Marketing
  • Intelligenza Artificiale
  • SEO & GEO
  • Web Marketing e Content
  • Google Analytics e Web Analytics
  • Google Ads & Advertising
  • YouTube
  • TikTok, Instagram e altri Social
  • Google Adsense, Affiliazioni e Guadagno
  • E-Commerce
  • Coding e Sistemistica
  • Help Center: consigli per il tuo progetto
  • Hosting e Cloud
  • Coding
  • CMS & Piattaforme Self-Hosted
  • Annunci e Collaborazioni
  • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
  • Collaborazioni WEB e Lavoro: offro e cerco
  • Impresa, Fisco e Leggi
  • Consulenza Legale e Professioni Web
  • Consulenza Fiscale, Imprese, Startup e P.Iva
  • Gli Off Topic
  • PC, Smartphone e altri Hardware
  • Tutti i Software
  • GT Fetish Cafè
  • Discussioni
  • 0 Non letti 0
  • Recenti
  • Hashtag
  • Popolare
  • Utenti
  • Privacy
  • Termini e condizioni
  • © 2026 Search On Media Group S.r.l.
Collassa
Connect.gt
Il network Search On
Connect.gt WMF AI Festival Accademia Advanced SEO Tool AgentCy Social Media Strategies Search Tech
Registrati Accedi
Connect.gt
Stream Interest Categorie Hashtag
  1. La community italiana di SEO, marketing digitale e AI
  2. Categorie
  3. Coding e Sistemistica
  4. Coding
  5. creare file formvalidate.php da codice javascript

creare file formvalidate.php da codice javascript

Pianificato Fissato Bloccato Spostato Coding
1 Post 1 Autori 878 Visualizzazioni 1 Seguito
  • Da Vecchi a Nuovi
  • Da Nuovi a Vecchi
  • Più Voti
Rispondi
  • Risposta alla discussione
Effettua l'accesso per rispondere
Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
  • F
    F
    five
    Bannato
    scritto su ultima modifica di
    User Newbie 0
    #1
    creare file formvalidate.php da codice javascript

    Ciao a tutti, è da poco che studio javascript e in questo mese ho cercato di programmare alcune cose particolari che mi servivano per i miei siti. In questi giorni sto cercando di creare un file in php (questo deve permettere di validare dei campi specifici del form)ma con tutta la buona volontà anche cercando sul web guide o consigli non ci riesco. Magari voi ne sapete più di me e quindi potete dire la vostra.
    Vi posto il codice che ho usato nel file javascript e da quello dovremmo ricavare il file php. Inoltre nel codice troverete scritto nel codice formValidator.php che poi sarà sostituito con il file che stiamo per creare.
    Ecco qui il codice:

    $(document).ready(function() {
        var checkUser = function (username) {
            //remove all the class add the messagebox classes and start fading
            $("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
            var username = $('#username').val();
            $.post(
                "validateForm.php",
                {check: 'username', user: username},
                function(data) {
                    if(data=='no') { //if username not avaiable
                          $("#msgbox").fadeTo(200,0.1,function() { //start fading the messagebox
                            //add message and change the class of the box and start fading
                              $(this).html('User unavailable for registration!').addClass('messageboxerror').fadeTo(900,1);
                            $('input[type=button]').attr('disabled', 'disabled');
                        });
                          }
                      else if(data=='yes') {
                          $("#msgbox").fadeTo(200,0.1,function() {  //start fading the messagebox
                              //add message and change the class of the box and start fading
                              $(this).html('User available for registration!').addClass('messageboxok').fadeTo(900,1);
                            $('input[type=button]').attr('disabled', false);    
                        });
                      }
                    else if(data=='no_db_server_connection') {
                        $("#msgbox").fadeTo(200,0.1,function() {  //start fading the messagebox
                              //add message and change the class of the box and start fading
                              $(this).html('The mySQL server is down!').addClass('messageboxerror').fadeTo(900,1);
                            $('input[type=button]').attr('disabled', 'disabled');
                        });
                    }
                    else if(data=='no_db_connection') {
                        $("#msgbox").fadeTo(200,0.1,function() {  //start fading the messagebox
                              //add message and change the class of the box and start fading
                              $(this).html('The specified database does not exist!').addClass('messageboxerror').fadeTo(900,1);
                            $('input[type=button]').attr('disabled', 'disabled');
                        });
                    }
                }            
            )
        }
        var checkPass = function (password) {
            $("#pmsgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
            var password = $('#password').val();
            var cpassword = $('#cpassword').val();
            if(password != cpassword) {
                $("#pmsgbox").fadeTo(200,0.1,function() { //start fading the messagebox
                    //add message and change the class of the box and start fading
                    $(this).html('Passwords do no match!').addClass('messageboxerror').fadeTo(900,1);
                    $('input[type=button]').attr('disabled', 'disabled');
                });
            }
            else {
                $("#pmsgbox").fadeTo(200,0.1,function() { //start fading the messagebox
                    //add message and change the class of the box and start fading
                    $(this).html('Passwords match!').addClass('messageboxok').fadeTo(900,1);
                    $('input[type=button]').attr('disabled', false);
                });    
            }        
        }
        var checkEmail = function (email) {
            $("#emsgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
            var email = $("#email").val();
            $.post(
                "validateForm.php",
                {check: 'email', emailAddress: email},
                function(data) {
                    if(data=='no') { //if username not avaiable
                          $("#emsgbox").fadeTo(200,0.1,function() { //start fading the messagebox
                            //add message and change the class of the box and start fading
                              $(this).html('Email address unavailable for registration!').addClass('messageboxerror').fadeTo(900,1);
                            $('input[type=button]').attr('disabled', 'disabled');
                        });        
                          }
                      else if(data=='invalid') { //if username not avaiable
                          $("#emsgbox").fadeTo(200,0.1,function() { //start fading the messagebox
                            //add message and change the class of the box and start fading
                              $(this).html('Email address provided is invalid!').addClass('messageboxerror').fadeTo(900,1);
                        });        
                          }
                      else if(data=='yes'){
                          $("#emsgbox").fadeTo(200,0.1,function() {  //start fading the messagebox
                              //add message and change the class of the box and start fading
                              $(this).html('Email address available for registration!').addClass('messageboxok').fadeTo(900,1);
                            $('input[type=button]').attr('disabled', false);    
                        });
                      }
                    else if(data=='no_db_server_connection') {
                        $("#emsgbox").fadeTo(200,0.1,function() {  //start fading the messagebox
                              //add message and change the class of the box and start fading
                              $(this).html('The mySQL server is down!').addClass('messageboxerror').fadeTo(900,1);
                            $('input[type=button]').attr('disabled', 'disabled');
                        });
                    }
                    else if(data=='no_db_connection') {
                        $("#emsgbox").fadeTo(200,0.1,function() {  //start fading the messagebox
                              //add message and change the class of the box and start fading
                              $(this).html('The specified database does not exist!').addClass('messageboxerror').fadeTo(900,1);
                            $('input[type=button]').attr('disabled', 'disabled');
                        });
                    }    
                }            
            )
        }
        $("#username").blur(checkUser);
        $("#cpassword").blur(checkPass);
        $("#email").blur(checkEmail);
    });
    

    Il form in html lo dispongo di già e funziona tutto tranne che manca questo file che fa riferimento al file postato qui sopra.

    Praticamete in quel file ci deve essere la validazione dei campi e quindi dire se l'username e l'email esiste...magari controllandolo da un datebase specifico.

    Se volete alcune precisioni ve le darò di sicuro. Grazie per l'aiuto,mi metto a lavoro anche io.!!!

    1 Risposta Ultima Risposta
    Miglior risposta 0
    0

    Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.

    Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.

    Con il tuo contributo, questo post potrebbe essere ancora migliore 💗

    Registrati Accedi
    Rispondi
    • Risposta alla discussione
    Effettua l'accesso per rispondere
    • Da Vecchi a Nuovi
    • Da Nuovi a Vecchi
    • Più Voti


    • Accedi

    • Non hai un account? Registrati

    • Accedi o registrati per effettuare la ricerca.
    • Primo post
      Ultimo post
    Home Accedi Registrati
    Menu
    • CATEGORIES
    • La Community Connect.gt
    • Presentati alla Community
    • News Ufficiali da Connect.gt
    • Internet News
    • A Scuola Di
    • Digital Marketing
    • Intelligenza Artificiale
    • SEO & GEO
    • Web Marketing e Content
    • Google Analytics e Web Analytics
    • Google Ads & Advertising
    • YouTube
    • TikTok, Instagram e altri Social
    • Google Adsense, Affiliazioni e Guadagno
    • E-Commerce
    • Coding e Sistemistica
    • Help Center: consigli per il tuo progetto
    • Hosting e Cloud
    • Coding
    • CMS & Piattaforme Self-Hosted
    • Annunci e Collaborazioni
    • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
    • Collaborazioni WEB e Lavoro: offro e cerco
    • Impresa, Fisco e Leggi
    • Consulenza Legale e Professioni Web
    • Consulenza Fiscale, Imprese, Startup e P.Iva
    • Gli Off Topic
    • PC, Smartphone e altri Hardware
    • Tutti i Software
    • GT Fetish Cafè
    • Discussioni
    • Non letti 0
    • Recenti
    • Hashtag
    • Popolare
    • Utenti
    • Privacy
    • Termini e condizioni
    • © 2026 Search On Media Group S.r.l.