tags:

views:

38

answers:

2

So this works fine on FF, safari: html file:

$('#maj_password_email').submit(function(){
var _data= $(this).serialize()

  $.ajax({
        type: 'POST',
        url: 'valid.php?var=maj_password_email',
        data:_data,
       dataType:"html",
        cache: false,
        success: function(html){
         $('div#error').html(html)
text=$('div#error').html()
switch(text){
  case "<b>entrer un email svp</b>":
$("#maj_password_email").slideUp()
  break
             }
         }
     })
})

the php file

 foreach ($_POST as $key => $value){
  $$key = mysql_real_escape_string(utf8_decode($value));

}   
if($_GET["var"]=="maj_password_email"){


      if( trim($email)=="" ){
            echo "<b>entrer un email svp</b>";
      }

     else{


       }
    }

so this same example doesnt work on ie , the form doesnt slide up when the string "entrer un email svp" enters the error div, this would work on ie if i get rid of the bold tag inside the string, so putting 'the break tag, the bold tag etc inside the string doesnt work on ie, im trying to find out why as i would like to style certain aspect of my error message this way.

A: 

You better check the length rather then equality of a string, then you should check the email patter [email protected]

Check the following links :

http://www.linuxjournal.com/article/9585

http://www.codewalkers.com/c/a/Miscellaneous/Email-Validation-with-PHP/

c0mrade
i know about email patterns...that's not the question.
tada
you better check the lentgh, BESt ANSWER
tada
+1  A: 

For form validation on the client side with jQuery, you may find it much easier to use jQuery's validation plugin: http://docs.jquery.com/Plugins/validation

And in the PHP script, have you forgotten to define $email ?

In your JavaScript, I suggest using semicolons on the ends of lines, and not naming variables basic things like "html" as there may be variables in scope with the same name.

Also it may be helpful to try to wrap your JSON keys in quotations?

Johnus
Ok so no one knows..
tada
I hadn't planned on testing it for you. But your JavaScript is badly formatted and doesn't follow all conventions. Different browsers are less/more strict on JavaScript correctness. Try my suggestions and see if it makes a difference?
Johnus
If you dont use semicolons in Js no browser will care about this.
tada