Results 1 to 5 of 5

Thread: Problem: dialog box alert () with chrome + safari

  1. #1
    Join Date
    Jul 2009
    Posts
    79

    Problem: dialog box alert () with chrome + safari

    I have a small problem with JavaScript in safari and google chrome (not yet tested with firefox).

    Let me explain: I'm enthusiasm to create a new website for our company and it is a party with a form. In this form I must control the content before sending. That is to say whether all fields are filled, etc. If a field is missing, I have a box dialog (function alert ()) that appears informing me to fill in empty areas.

    Under IE8 it works very well, but in Chrome or Safari, when I validate the form, even as some fields or all fields are empty, it sends back a form without any data without my dialog box appears.

    Does someone has an idea where the problem may be?

    Here is the code form ( "envoi.inc.php" retrieves the data and transmit them by mail to an address in-house):

    HTML Code:
    <form action="inc/envoi.inc.php" method="post" enctype="multipart/form-data" name="formula" onsubmit="MM_validateForm('nom','','R','prename','','R','address','','R','numero','','R','cp','','R','commune','','R','telephone','','R','email','','RisEmail');return document.MM_returnValue"> 
     
    Name :<br><input type="text" name="name" size=30><span class="Style25">*</span></br> 
    Prename :<br><input type="text" name="prename" size=30><span class="Style25">*</span></br> 
    Address :<br><input type="text" name="address" size=30><span class="Style25">*</span> N° : <input type="text" name="numero" size="4"><span class="Style25">*</span></br? 
    Code Postal :<br><input type="text" name="cp" size="4"><span class="Style25">*</span></br> 
    Commune :<br><input type="text" name="community" size=30><span class="Style25">*</span></br> 
    Tel :<br><input type="text" name="telephone" size=30><span class="Style25">*</span></br> 
    E-mail :<br><input type="text" name="email" size=30><span class="Style25">*</span></br> 
    Relates :  
     <SELECT name="list" size="1" class="style1"> 
     <OPTION VALUE="0">Choose</OPTION> 
     <OPTION VALUE="1">A</OPTION> 
     <OPTION VALUE="2">Two</OPTION> 
     <OPTION VALUE="3">Other</OPTION> 
     </SELECT>< /br> 
    Your message :<br><textarea name="comment" rows="10" cols="50"></textarea>< /br> 
    <input class="style1" type="submit" name="Send" VALUE="Send"> 
    <input class="style1" type="reset" VALUE="Clear"> 
    </form>
    here is the script of checking fields:

    HTML Code:
    function MM_validateForm() 
     { 
     if (document.getElementById) 
      { 
      var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; 
      for (i=0; i<(args.length-2); i+=3) 
       { 
       test=args[i+2]; 
       val=document.getElementById(args[i]); 
       if (val) 
        { 
        nm=val.name; 
        if ((val=val.value)!="" ) 
         { 
         if (test.indexOf('isEmail')!=-1) 
          { 
          p=val.indexOf('@'); 
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain a valid email address.\n'; 
          } 
         else if (test!='R') 
          { 
          num = parseFloat(val); 
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; 
          if (test.indexOf('inRange') != -1) 
           { 
           p=test.indexOf(':'); 
           min=test.substring(8,p); 
           max=test.substring(p+1); 
           if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; 
           } 
          } 
         } 
        else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; 
        } 
       } if (errors) alert('The following errors must be corrected:\n'+errors); 
       document.MM_returnValue = (errors == ''); 
      } 
     }

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Problem: dialog box alert () with chrome + safari

    Hmm, instead:
    HTML Code:
    val = document.getElementById (args [i]);
    I would put this instead:
    HTML Code:
    document.formula val = [args [i]]

  3. #3
    Join Date
    Jul 2009
    Posts
    79

    Re: Problem: dialog box alert () with chrome + safari

    This is not what will solve my problem?

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Problem: dialog box alert () with chrome + safari

    Bah, make getElementById on elements that have no ID, do not be surprised if it only works on IE ...

  5. #5
    Join Date
    Jul 2009
    Posts
    79

    Re: Problem: dialog box alert () with chrome + safari

    Quote Originally Posted by Zecho View Post
    Bah, make getElementById on elements that have no ID, do not be surprised if it only works on IE ...
    Thank you very much, now it works very well

Similar Threads

  1. Google Chrome Vs Safari
    By Adikavi in forum Technology & Internet
    Replies: 5
    Last Post: 07-01-2010, 10:09 PM
  2. Safari Style RSS Feed Subscription on Chrome
    By KAMAL60 in forum Technology & Internet
    Replies: 5
    Last Post: 24-12-2009, 12:11 AM
  3. Run Google Chrome, IE, Firefox & Safari from USB
    By Aakarshan.d in forum Windows Software
    Replies: 4
    Last Post: 05-03-2009, 08:27 AM
  4. Safari Not Affected by Google's Chrome
    By Joachim in forum Technology & Internet
    Replies: 1
    Last Post: 18-09-2008, 05:01 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,507,054.22495 seconds with 16 queries