6

How can I replace the prompt in this code with a simple UI dialog to achieve the same thing. IE is warning about security when using prompt.

HTML:

<input type="text" id="txt1" name="textbox1">
<input type="button" id="btn" name="buttonExecute" value="Enter number">

JavaScript:

$('#btn').click(function() {
    var n = prompt('Please enter number');
    if ( n!=null && n!="" ) {

    var fixed=n.substr(1,9);

     $('#txt1').val(fixed);
    }
});

2 Answers 2

8

Use jQuery UI.

See a simple demo here. http://jsfiddle.net/5yhmb/23/

Sign up to request clarification or add additional context in comments.

3 Comments

very good but I tried to put this code in and it won't work. var fixed=text2.substr(1,9); $('#txt1').val(fixed);
@Ntguy, you need use text2.val().substr(1,9); jsfiddle.net/maheshep/5yhmb/21 because $('#txt1') return an input object not string.
@Ntguy, I used query jQuery and jQueryUI. you will have to download it.
0

Have a look at the jQuery UI Dialog widget: http://jqueryui.com/demos/dialog/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.