Skip to content

Commit

Permalink
Add support for maxlength option
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew committed Feb 20, 2015
1 parent da3fc34 commit de4dc51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bootbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@
input.attr("pattern", options.pattern);
}

if (options.maxlength) {
input.attr("maxlength", options.maxlength);
}

// now place it in our form
form.append(input);

Expand Down
8 changes: 8 additions & 0 deletions tests/prompt.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ describe "bootbox.prompt", ->
it "has correct pattern value", ->
expect(@find("input[type='text']").prop("pattern")).to.equal "\d{1,2}/\d{1,2}/\d{4}"

describe "with maxlength", ->
beforeEach ->
@options.maxlength = 5
@create()

it "has correct maxlength value", ->
expect(@find("input[type='text']").prop("maxlength")).to.equal 5

describe "setting inputType textarea", ->
beforeEach ->
@options.inputType = "textarea"
Expand Down

0 comments on commit de4dc51

Please sign in to comment.