CodeIgniter Forums
Add some jQuery FadeIn to error message in forms! [Resolved] - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Add some jQuery FadeIn to error message in forms! [Resolved] (/showthread.php?tid=31475)



Add some jQuery FadeIn to error message in forms! [Resolved] - El Forum - 06-21-2010

[eluser]ludovic_r[/eluser]
Hello all,

I've a little problem that I can't fix myself :'( Here it is :

I've made a newsletter with the "Form" helper and everything work fine. The only thing I want is to add some magical effects on the error messages like a FadeIn when an error message appear and so on.

That's what I tried :

Code:
<head>

[removed]
        $(function(){
            $(document).mousemove(function(){
                $(".errors").fadeIn(500);
            });
        });
    [removed]
    
    <style type="text/css">
        .errors{
            display:none;
            }
    </style>
    
    
</head>
<body>

<h2>test view</h2>

&lt;?php echo form_open('email/send'); ?&gt;

<p>
    <label for="name">Email address: </label>
    &lt;input placeholder="Write here" type="text" name="email" id="email" value="&lt;?php echo set_value('email'); ?&gt;"&gt;
</p>

&lt;?php echo form_submit('submit', 'Submit'); ?&gt;
&lt;?php echo validation_errors('<p class="errors">'); ?&gt;

    
&lt;?php echo form_close(); ?&gt;

&lt;/body&gt;
&lt;/html&gt;

As you can see at the end I have the "validation_errors" with the class "errors" and I tried to add a jQuery script with a FadeIn and it works well but only when the "mousemove" event is called.

All I want to do is to have this FadeIn when the error message appear (like : "please put a valide mail") Not on mousemove event.


Anyone can help me? It would be very helpful!

Many thanks!


Add some jQuery FadeIn to error message in forms! [Resolved] - El Forum - 06-21-2010

[eluser]cahva[/eluser]
You can execute the script as soon as the document is loaded(ie. you dont have to bind event to that):
Code:
$(function() {
    $(".errors").fadeIn(500);
});



Add some jQuery FadeIn to error message in forms! [Resolved] - El Forum - 06-21-2010

[eluser]ludovic_r[/eluser]
Thank you so much! I'm so blind, I didn't see this possibility! It works great now!


Add some jQuery FadeIn to error message in forms! [Resolved] - El Forum - 06-21-2010

[eluser]pkrstic[/eluser]
$(document).ready(function(){
$(".errors").fadeIn(500);
});


Add some jQuery FadeIn to error message in forms! [Resolved] - El Forum - 06-21-2010

[eluser]cahva[/eluser]
[quote author="pkrstic" date="1277135248"]$(document).ready(function(){
$(".errors").fadeIn(500);
});[/quote]

Ehm.. Why? $(function() { is shorhand for $(document).ready(function(){