In JavaScript (with jQuery) I want to prompt for email inside document ready block

252 Views Asked by At

I have an html page that I want to have a javascript variable email. When the html page loads, I want the first thing to happen is a simple modal dialog pops up and prompts the user to enter a valid email. The user pushes an "OK" or "Cancel" button, then I get the email address. Nothing fancy, just a simple alert type dialog. I use Impromptu but can't figure it out.

That is, in sort of pseudo code, this is what I'm trying to do:

    $(document).ready(function() {

      $.prompt("Enter Valid Email",function(val) { console.log('email:' + val); }

    }

I get that I've done nothing to put up a form but I'm struggling with how to do that (impromptu or something else).

1

There are 1 best solutions below

0
Arunkumar Vasudevan On BEST ANSWER

I don't Know right or Wrong. Have you tried this one Fiddle

        var statesdemo = {
            state0: {
                title: 'Enter Email',
                html:'<label>Email <input type="text" name="fname" value=""></label><br />',
                buttons: { Submit: 1 },
                //focus: "input[name='fname']",
                submit:function(e,v,m,f){
                    console.log(e,v,m,f);
                    e.preventDefault();
                }
            }
        };

        $.prompt(statesdemo);