Skip to content

Commit 5919e2a

Browse files
author
Tom Hanoldt
committed
strip non printable chars before validationg email, tel and numbers
1 parent f44902c commit 5919e2a

File tree

7 files changed

+39
-16
lines changed

7 files changed

+39
-16
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery.input.validator",
3-
"version": "1.1.8",
3+
"version": "1.1.9",
44
"homepage": "https://github.com/creative-workflow/jquery.input.validator",
55
"authors": [
66
"Tom Hanoldt <tom@creative-workflow.berlin>"

dist/jquery.input.validator.js

Lines changed: 20 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.input.validator.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.input.validator.min.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
##### 1.1.9
4+
* strip non printable chars before validationg email, tel and numbers
5+
36
##### 1.1.8
47
* fix required for radios
58

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery.input.validator",
3-
"version": "1.1.8",
3+
"version": "1.1.9",
44
"description": "This jquery plugin helps to handle html input validation. It uses strict html attributes to map the validation rules and is easy extendable.",
55
"main": "dist/jquery.input.validator.js",
66
"repository": {

src/input.validator.coffee

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ class @InputValidator
4040
rules:
4141
number: (validator, $element, value) ->
4242
return true if $element.attr('type') != 'number' || !(''+value).length
43-
validator.config.pattern.number.test(value)
43+
validator.config.pattern.number.test(validator.strip(value))
4444

4545
tel: (validator, $element, value) ->
4646
return true if $element.attr('type') != 'tel' || !(''+value).length
47-
validator.config.pattern.tel.test(value)
47+
validator.config.pattern.tel.test(validator.strip(value))
4848

4949
email: (validator, $element, value) ->
5050
return true if $element.attr('type') != 'email' || !(''+value).length
51-
validator.config.pattern.email.test(value)
51+
validator.config.pattern.email.test(validator.strip(value))
5252

5353
pattern: (validator, $element, value) ->
5454
return true if !$element.attr('pattern') || !(''+value).length
@@ -60,7 +60,7 @@ class @InputValidator
6060

6161
decimal: (validator, $element, value) ->
6262
return true unless $element.data('rule-decimal') || !(''+value).length
63-
validator.config.pattern.decimal.test(value)
63+
validator.config.pattern.decimal.test(validator.strip(value))
6464

6565
required: (validator, $element, value) ->
6666
return true unless $element.attr('required')
@@ -143,6 +143,15 @@ class @InputValidator
143143
@ns = 'ivalidator'
144144
@prepareElements(context)
145145

146+
strip: (input) ->
147+
ret = ''
148+
x = 0
149+
while x < input.length
150+
if input.charCodeAt(x) >= 33 and input.charCodeAt(x) <= 253
151+
ret += input.charAt(x)
152+
x++
153+
ret
154+
146155
prepareElements: (context=null) =>
147156
context ?= @context
148157

0 commit comments

Comments
 (0)