options.pattern won't work for prompt #554

Open
SleepWalker opened this Issue Oct 24, 2016 · 5 comments

Projects

None yet

2 participants

@SleepWalker

Hello,

when you specify options.pattern for prompt it will have no effect, when user click on confirm button (because confirm button won't trigger form submit and therefore validation). The validation will work only, when user presses enter inside input:

bootbox.prompt({
    title: "This is a prompt with a date input!",
    pattern: '^[a-z]{2}$',
    callback: function (result) {
        console.log(result);
    }
});

Bootbox v4.4.0

@tiesont tiesont added Bug? Bug and removed Bug? labels Oct 24, 2016
@tiesont
Collaborator
tiesont commented Oct 24, 2016 edited

@makeusabrew I can confirm this: https://jsfiddle.net/aknwe3ej/. I can work on a patch.

@tiesont
Collaborator
tiesont commented Oct 24, 2016

@SleepWalker I'm not jazzed about the changes I've made to get this workaround, but does this fiddle seem to work as expected? https://jsfiddle.net/aknwe3ej/1/

@SleepWalker
SleepWalker commented Oct 28, 2016 edited

It works, but it is too complicated. What do you think about this approach: https://jsfiddle.net/aknwe3ej/3/?

It would be cool to be able to show custom error messages, but this is completely another feature.

@tiesont
Collaborator
tiesont commented Oct 28, 2016

@SleepWalker Closer, but a native prompt doesn't require a non-empty input, so I'm not sure if @makeusabrew would want to go that route. Of course, a native prompt doesn't allow you to apply an input pattern or use alternate input types, soooo...

@SleepWalker
SleepWalker commented Oct 28, 2016 edited

I've added a new options.required. So it would work as native prompt, till you specify that option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment