Slimshadddyyy
Slimshadddyyy

Reputation: 4081

Alertify JS- Change button text on prompt dialog

$("#btn_submit").click(function(){
    alertify.prompt("Please enter note/remarks for this Form:", function (e, value) {
        $("#alertify-ok").val('Submit Form'); //change button text
            if (e) {
                alertify.success("Form has been submitted");
            } else {
                alertify.error("Your form is not submitted");
            }
        });

HTML for alertify prompt dialog

<button id="alertify-ok" class="alertify-button alertify-button-ok" type="submit">
    OK
</button>

The prompt appears when user clicks on submit button. Tried changing button text using below but its not working

$("#alertify-ok").val('Submit Form'); //change button text

Fiddle- where I need to change the default OK button text to something else

How could I change the button text to Submit Form instead of default OK ?

Upvotes: 5

Views: 14316

Answers (2)

Shaunak D
Shaunak D

Reputation: 20646

<button> has innerText property and does not have value. Use .text()

$("#alertify-ok").text('Submit Form'); //change button text

Use .set('labels') option to change default text.

alertify.prompt('Please enter your comments', 'some value', 
    function(evt, value){ alertify.message('You entered: ' + value);}
).set('labels', {ok:'Submit', cancel:'Cancel'});

Fiddle

Upvotes: 13

Anonymous Duck
Anonymous Duck

Reputation: 2998

Found this : alertify

alertify.prompt('Please enter your comments', 'some value', 
    function(evt, value){ alertify.message('You entered: ' + value);}
).set('labels', {ok:'Submit Form', cancel:'New Cancel'});

Upvotes: 1

Related Questions