Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

knockout validation regex not evaluating properly

I am using knockoutjs and knockout validation. I am attempting to restrict semicolons from being entered. I have tried this:

.extend({ pattern: { params: "[^;]"} });

..somehow when I enter 'pppppp' into my text input it is considered invalid. but 'eee' is valid, please help?

Thanks!

like image 338
user3133130 Avatar asked Apr 08 '26 06:04

user3133130


1 Answers

It would appear that you need to include a custom message, or not use a wrapping object.

Check out this js fiddle.

The following constructions are valid:

.extend({
    pattern: {
        params: '^[^;]*$'
        , message:"fail"
    }
})

or

extend({
    pattern: '^[^;]*$'
})

However, this results in unexpected behaviour:

.extend({
    pattern: {
        params: '^[^;]*$'
    }
})
like image 189
FrankieTheKneeMan Avatar answered Apr 10 '26 02:04

FrankieTheKneeMan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!