On 5 jun, 12:11, talisien <globalnewsgrab...@gmail.com> wrote:
> I'm having some troubles with passing variables to jQuery.format
>
> I have a script (php) that's checks if the domain part exists. If not
> it will show an message
>
> The following code works #1
>
> It split an email address and assigns the domain name to the var
> hostName
> $(document).ready(function() {
>
> var x = $('#email').val();
>         var ind=x.indexOf("@");
>         var hostName=x.slice((ind+1),x.length);
>
> .... rest of script
>
> it will correctly show the var hostName in jQuery.format, but after
> entering another incorrect domain name it will show the first
> incorrect domain name
>
> I've also tried this #2
>
> $(document).ready(function() {
>
> $("#email").blur(function () {
> var x = $('#email').val();
>         var ind=x.indexOf("@");
>         var hostName=x.slice((ind+1),x.length);
>
> }).blur();
>
> ...rest of script
> But then i got a message (firebug) that hostName is not defined
>
> #3
>
> $(document).ready(function() {
> $("#email").blur(function () {
> var x = $('#email').val();
>         var ind=x.indexOf("@");
>         var hostName=x.slice((ind+1),x.length);
>        alert(hostName);}).blur();
>
> .. rest of script
>
> This will show the domain name, but on loading page it will show an
> empty alert window
>
> I prefer method #2.
> How can i pass the var hostName to jQuery.format?
>
> Any help is much appreciated.

update: method #1 requires an refresh to show hostName

Reply via email to