• Home
  • Forum
  • Fare Web
  • Javascript

Problemi con Chrome e Safari

  • Creatore Discussione Creatore Discussione Tommy1981
  • Data di inizio Data di inizio 15 Ott 2010
T

Tommy1981

Utente Attivo
1 Mag 2010
84
0
0
  • 15 Ott 2010
  • #1
Ciao a tutti....

qualcuno sa dirmi perchè il seguente codice per un form di iscrizione, con javascript per il controllo dei campi su tutti gli IE, i Firefox e gli Opera funziona, mente su Safari e Chrome se ne sbatte altamente e registra qualunque cosa?

PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Join!</title>
<link href="SGT_CSS_1.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
    background-color: #999;
    background-image: url(Immagini/Home/Bg.gif);
    background-repeat: repeat-x;
}
-->
</style>
<script type="text/javascript">
<!--

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//-->

function CAPTCHA()
{
var car, min, max, dif, lun, inc;
car  = "abcdefghijklmnopqrstuvwxyz";
car += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
car += "1234567890";
min  = 5;
max  = 5;
dif  = max - min;
lun  = Math.round((Math.random() * dif) + min);
inc  = 0;
cod  = "";
while (inc < lun)
{
  cod += car.charAt(Math.round(Math.random() * car.length));
  inc++;
}
return cod;
}<!--Crea il captcha -->


function Prova(){
document.getElementById("captcha").innerHTML = CAPTCHA();<!--crea immagine captcha -->
}
</script><!--Java-->

</head>

<body onload=
"; Prova()">
<!--Rollover -->

<div id="centrale"><!--Banner alto --><!--Banner destro --><!--Titolo sito --><!--Sottotitolo -->
  
<div id="contenuti">
  <!--Immagine membership-->
  <!--Scritto per membership --><!--Immagine register -->
  
  <div id="Register">
  
  <?php
session_start();    // Maintain session state
header("Cache-control: private");    // Fixes IE6's back button problem.

// Dont allow members to go to add user page
if(@$_SESSION['user']) header("location: login.php");
elseif(@$_POST['user']){
    // Get and set vars (without html characters)
    $user = htmlspecialchars(strtolower($_POST["user"]));
    $pass = htmlspecialchars($_POST["pass"]);
    $permission = 0;        // Default: user, until admin changes
    $email = htmlspecialchars($_POST["email"]);
    $url = htmlspecialchars($_POST["url"]);

    // Add dots to date
    $joined = $_POST["joined"];

    // Create the string to append
    $string = "\r\n". $user. "<del>". md5($pass). "<del>". $permission. "<del>". $email. "<del>". $joined;

    // Make sure username doesn't already exist
    //-----------------------------------------
    // Include the flat-file
    $file = file("users.php") or die("Problem getting the user details flat-file [users.php]");

    // Get the size of file
    $totalLines = sizeof($file);

    // Get the users details line by line
    $line = 0;
    $match = 0;
    do{
        // Check the line isn't a comment
        if("//" != substr($file[$line], 0, 2)){
            // Break our records up
            @list($username, $password, $permission, $email, $url, $joined) = explode("<del>", $file[$line]);

            // Check the username and passwords match
            if((strtolower($user) == strtolower($username))) $match = 0;
            else $match = 0;
        }

        // Exit loop if match found
        if($match) break;
            
        // Increment line count
        $line++;
    } while($line < $totalLines);

    // Only add new user if a match is not found
    if($match){
    ?>
        <script language = "javascript" type = "text/javascript">
        <!-- // Go back
            alert("Username already taken, taking you back to choose another");
            history.go(-1);
        -->
        </script>
      <?php
    }
    else{
        // Open the users file
        $fp = fopen("users.php", "a+");

        // Append the new user to end of users file
        fwrite($fp, $string);

        // Close the file
        fclose($fp);

        // Redirect to index
        header("location: index.php?new=1");
    }
}
else{
?>
      <?php
}
?>

       <form method = "post" action = "<?php print($_SERVER['PHP_SELF']); ?>">
        <table width="451" border = "0" align = "left" cellpadding = "10" cellspacing = "0" style = "height: 80%; text-align: left;">
    <tr>
        <td height="52" colspan = "3" align="left" valign = "top">
            <span class = "bold">Join our member list!</span></td>
    </tr>
    <tr>
        <td width = "162" height = "10" align="left" valign = "top">
            <span class = "hilight">Username:</span>
        </td>
        <td width = "249" height = "10" align="left" valign = "top">
            <input name = "user" type = "text" class = "text" id = "user" style = "width: 80%" tabindex = "1" maxlength="20">
    </tr>
    <tr>
        <td width = "162" height = "10" align="left" valign = "top">
            <span class = "hilight">Password:</span>
        </td>
        <td width = "249" height = "10" align="left" valign = "top">
            <input name = "pass" type = "password" class = "text" id = "pass" style = "width: 80%" tabindex = "2" maxlength="20">
        </td>
    </tr>
    <tr>
        <td width = "162" height = "10" align="left" valign = "top">
            <p class="hilight"> Repeat Password:</p></td>
        <td width = "249" height = "10" align="left" valign = "top">
            <p>
              <input name = "pass2" type = "password" class = "text" id = "pass2" style = "width: 80%" tabindex = "3" maxlength="20">
            </p></td>
    </tr>
    <tr>
        <td width = "162" height = "10" align="left" valign = "top">
            Email:
        </td>
        <td width = "249" height = "10" align="left" valign = "top">
            <input type = "text" id = "email" name = "email" style = "width: 80%" class = "text" tabindex = "4">
        </td>
    </tr>
    <tr>
        <td width = "162" height = "10" align="left" valign = "top">
            Repeat Email:
        </td>
        <td width = "249" height = "10" align="left" valign = "top">
            <input type = "text" id = "url" name = "url" style = "width: 80%" class = "text" tabindex = "5">
        </td>
    </tr> 
    <tr>
        <td width = "162" height = "10" align="left" valign = "top">
            Join our newsletter:
        </td>
        <td width = "249" height = "10" align="left" valign = "top"><label>
          <input type="checkbox" name="news" id="news" value="news" /></label>
          <a href="Javascript:newsletter()" class="Linkage">About newsletter</a></td>
    </tr>
    <tr>
        <td width = "162" height = "10" align="left" valign = "top">
            Read and approve privacy policy:
        </td>
        <td width = "249" height = "10" align="left" valign = "top"><label>
          <input type="checkbox" name="privacy" id="privacy" value="privacy" />
          </label>
        <a href="Javascript:privacy()" class="Linkage">Privacy policy</a></td>
    </tr>
    <tr>
        <th width="199" height="74" scope="row"><p>Enter code from image (case sensitive):</p></th>
        <td width="181"><label>          
          <center>
            <span id="captcha"></span>     <br><br>
            <input name="key2" type="text" id="key2" size="10">
            <input name="refrefh" type="button" class="Bold" id="refrefh" value="New code" onclick="Prova()" />
          </center>
        </label>        
        </td>
        </tr>
    <tr>
        <td  width = "100" height = "79" colspan = "3" valign = "top"><input name = "submit" type = "Image" tabindex = "10" onfocus = "return checkFields();" src = "Immagini/Enter/Join.gif" alt = "arrow pointing right: next" align = "middle"/>          <input type = "hidden" name = "joined" value = "<?php print(date("d.m.Y H:i:s", mktime())); ?>" /></td>
    </tr>
</table>
</form> <!--Form registrazione -->

<script language = "javascript" type = "text/javascript">
<!--// Check field values are correct before submitting
    function checkFields(){
        var flag = 1;    // Return flag
// Check for empty values in important fields first
        if(!document.getElementById("user").value || !document.getElementById("pass").value || !document.getElementById("pass2").value || !document.getElementById("email").value ||!document.getElementById("url").value ||!document.getElementById("news").value||!document.getElementById("privacy").value||!document.getElementById("key2").value){
            alert("Please enter all values, join the newsletter and approve privacy terms");
            document.getElementById("user").focus();
            return true;
        }
        // Check that passwords are the same
        else if(document.getElementById("pass").value != document.getElementById("pass2").value){
            alert("Please enter two matching passwords");
            document.getElementById("pass").value = '';
            document.getElementById("pass2").value = '';
            document.getElementById("pass").focus();
            return true;
        }
        // Check that email are the same
        else if(document.getElementById("email").value != document.getElementById("url").value){
            alert("Please enter two matching email");
            document.getElementById("email").value = '';
            document.getElementById("url").value = '';
            document.getElementById("email").focus();
            return true;
        }
        <!--controllo captcha -->
        else if (document.getElementById("key2").value != document.getElementById("captcha").innerHTML)
        {
        alert("Please enter a correct code");
        document.getElementById("key2").value = "";
        document.getElementById("key2").focus();
        return true
        }
        <!--controllo newsletter -->
        if(document.forms[0].news.checked != true) {
        alert("Please join our newsletter");
        document.forms[0].news.focus();
        return false;
        }
        <!--controllo privacy -->
        if(document.forms[0].privacy.checked != true) {
        alert("Please, you need to accept privacy policy");
        document.forms[0].privacy.focus();
        return false;
        }
        else flag = 0;

        // One final check if the others went through fine
        if(!flag){
            if(document.getElementById("email").value){
                // Finally, check the email
                if(document.getElementById("email").value.indexOf("@") == -1 || document.getElementById("email").value.indexOf(".") == -1){
                    alert("Please make sure email is valid");
                    document.getElementById("email").focus();
                    return true;
                }
                else return false;
            }
            else return false;
        }
    }

-->
</script>
<script type="text/javascript">
<!-- finestra privacy
 
function privacy() {
window.open('privacy.html','Privacy','width=400','height=300');
}
-->
</script>
<script type="text/javascript">
<!-- finestra newsletter
  
function newsletter() {
window.open('newsletter.html','Newsletter','width=400','height=300');
}
-->
</script>
  </div>
  
  <!--Registrazione -->
  
</div> <!--Contenuti-Finestra centrale --><!-- Menù -->

</div> <!-- Container -->
</body>
</html>
 
T

Tommy1981

Utente Attivo
1 Mag 2010
84
0
0
  • 15 Ott 2010
  • #2
....mmm....stavo studiando un pò....forse il problema non è nei Jave ma nella funzione "onfocus"....
 
T

Tommy1981

Utente Attivo
1 Mag 2010
84
0
0
  • 16 Ott 2010
  • #3
Confermo....onFocus con Chrome e Safari fa cilecca..... Ho risolto usando onclick e sottomettendo il post del form nel java.... onclick = parte lo script... if tutto è a posto else post e action del form.....
 
Devi accedere o registrarti per poter rispondere.

Discussioni simili

Z
problemi con swf e chrome o sistemi portatili
  • zioweb
  • 26 Nov 2016
  • Webdesign e Grafica
Risposte
5
Visite
3K
Webdesign e Grafica 3 Feb 2017
Max 1
S
[HTML] Problemi con Blueimp image gallery su Chrome e Firefox
  • s.errani
  • 21 Nov 2016
  • HTML e CSS
Risposte
2
Visite
2K
HTML e CSS 21 Nov 2016
s.errani
S
E
layout responsive problemi con google chrome su smartphone android e win 8
  • Emanuele.Basilicata
  • 4 Set 2014
  • HTML e CSS
Risposte
0
Visite
2K
HTML e CSS 4 Set 2014
Emanuele.Basilicata
E
I
problemi con thunderbird
  • ilprincipiante
  • 9 Lug 2024
  • Posta Elettronica
Risposte
0
Visite
2K
Posta Elettronica 9 Lug 2024
ilprincipiante
I
T
problemi con dati menu a tendina
  • tregafabio
  • 22 Giu 2023
  • HTML e CSS
Risposte
2
Visite
2K
HTML e CSS 22 Giu 2023
tregafabio
T
M
Upload immagine con javascript problemi con FormData()
  • MBlackmore
  • 6 Ott 2021
  • Javascript
Risposte
1
Visite
1K
Javascript 6 Ott 2021
MBlackmore
M
A
Problemi con move_uploaded_file
  • antonio corizzo
  • 22 Giu 2021
  • PHP
Risposte
7
Visite
2K
PHP 27 Giu 2021
antonio corizzo
A
M
  • Bloccata
Problemi con la stampa dei valori in php
  • Mollichina
  • 21 Mag 2021
  • PHP
Risposte
1
Visite
1K
PHP 21 Mag 2021
Max 1
L
  • Bloccata
Problemi con il login
  • Laura2002
  • 18 Mag 2021
  • PHP
Risposte
2
Visite
1K
PHP 18 Mag 2021
Max 1
R
Tutto su utf-8 ma ancora problemi con i caratteri speciali in mysql
  • rob466
  • 27 Mar 2021
  • MySQL
Risposte
1
Visite
1K
MySQL 30 Mar 2021
rob466
R
Z
problemi con foreach insert into
  • Zhilang
  • 6 Feb 2021
  • PHP
Risposte
10
Visite
1K
PHP 7 Feb 2021
illiterate2020
I
B
javascript per problemi con pdf e Safari
  • bibliofila
  • 7 Gen 2021
  • Javascript
Risposte
0
Visite
3K
Javascript 7 Gen 2021
bibliofila
B
M
  • Bloccata
Problemi con creazione maschere
  • Mondo
  • 18 Nov 2020
  • Presentati al Forum
Risposte
1
Visite
887
Presentati al Forum 18 Nov 2020
Max 1
M
Problemi con query a più tabelle
  • Max61
  • 24 Ago 2020
  • PHP
Risposte
3
Visite
1K
PHP 25 Ago 2020
Hormus
H
S
Problemi delle funzioni eliminate con PHP e MySQL
  • Silvio0505
  • 20 Mag 2020
  • PHP
Risposte
4
Visite
2K
PHP 20 Mag 2020
Silvio0505
S
M
Problemi con blog Grav
  • Marea
  • 8 Mag 2020
  • CMS (Content Management System)
Risposte
0
Visite
2K
CMS (Content Management System) 8 Mag 2020
Marea
M
S
incoerenza di stampa. problemi con il magenta
  • smania80
  • 16 Mar 2020
  • Photoshop
Risposte
3
Visite
2K
Photoshop 24 Set 2020
rickiwada
R
A
problemi con paypall
  • Akille67
  • 29 Feb 2020
  • Java
Risposte
1
Visite
2K
Java 29 Feb 2020
Max 1
S
Problemi con modulo upload video php (help!)
  • silvio pacicca
  • 8 Ago 2019
  • PHP
Risposte
0
Visite
646
PHP 8 Ago 2019
silvio pacicca
S
[Windows 8.1] Problemi con connessione WiFi
  • felino
  • 28 Giu 2019
  • Windows e Software
Risposte
0
Visite
2K
Windows e Software 28 Giu 2019
felino
Condividi:
Facebook X (Twitter) LinkedIn WhatsApp e-mail Condividi Link
  • Home
  • Forum
  • Fare Web
  • Javascript
  • Italiano
  • Termini e condizioni d'uso del sito
  • Policy Privacy
  • Aiuto
  • Home
Community platform by XenForo® © 2010-2024 XenForo Ltd. | Traduzione a cura di XenForo Italia
Menu
Accedi

Registrati

  • Home
  • Forum
    • Nuovi Messaggi
    • Cerca...
  • Novità
    • Featured content
    • Nuovi Messaggi
    • Ultime Attività
X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?

X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?