Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 631
Slimshadddyyy Avatar asked Jun 29 '15 12:06

Slimshadddyyy


2 Answers

<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

like image 75
Shaunak D Avatar answered Sep 26 '22 17:09

Shaunak D


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'});
like image 20
DarkMakukudo Avatar answered Sep 25 '22 17:09

DarkMakukudo