mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-20 10:01:19 +00:00
Strip some characters from pasted date input
This commit is contained in:
@@ -30,7 +30,18 @@ export class DateComponent
|
||||
|
||||
placeholder: string
|
||||
|
||||
// prevent chars other than numbers and separators
|
||||
onPaste(event: ClipboardEvent) {
|
||||
let clipboardData: DataTransfer =
|
||||
event.clipboardData || window['clipboardData']
|
||||
if (clipboardData) {
|
||||
let pastedText = clipboardData.getData('text')
|
||||
pastedText = pastedText.replace(/[\sa-z#!$%\^&\*;:{}=\-_`~()]+/g, '')
|
||||
event.preventDefault()
|
||||
this.value = pastedText
|
||||
this.onChange(pastedText)
|
||||
}
|
||||
}
|
||||
|
||||
onKeyPress(event: KeyboardEvent) {
|
||||
if ('Enter' !== event.key && !/[0-9,\.\/-]+/.test(event.key)) {
|
||||
event.preventDefault()
|
||||
|
||||
Reference in New Issue
Block a user