Browse Source

Adds #1858, case sensitive/insensitive form validation rules

pull/1875/head
jlukic 10 years ago
parent
commit
a690601b3f
4 changed files with 49 additions and 11 deletions
  1. 8
      RELEASE-NOTES.md
  2. 42
      src/definitions/behaviors/form.js
  3. 4
      src/definitions/collections/form.less
  4. 6
      src/themes/default/collections/form.variables

8
RELEASE-NOTES.md

@ -2,12 +2,16 @@
### Version 1.9.4 - February 21, 2015
**Changes**
- **Form Validation** - Adds `containsExactly`, `notExactly`, `isExactly` case sensitive validation rules, make `contains`, `not`, `is` case insensitive.
- **Form Validation** - `contains` rule is now case insensitive
- **Form Validation** - Validation messages no longer increase field height on `inline fields` like checkboxes after error appears
- **Build Tools** - Fixed issue with recursive merge for site themes in update scripts, [details here](https://github.com/Semantic-Org/Semantic-UI/pull/1845) Thanks @derekslife
- **API** - Added `was cancelled` to determine whether request was cancelled by `beforeSend`
- **State** - Text states now handle `cancelled` API requests correctly
- **Search** - Category search no longer displays unnecessary error message about setting maxResults
- **Search** - Category search no longer displays unnecessary error message about maxResults
- **Composer** - Composer.json should now read version from tags, adjusted some fields.
- **Grid** - Stackable grid now has horizontal padding on mobile unless inside a `ui grid` or `ui segment`
- **Grid** - Stackable grid now has horizontal padding by default on mobile unless nested inside a `ui grid` or `ui segment` (not vertical)
- **Menu** - Fixes pointing menu displaying under dropdown menu
### Version 1.9.3 - February 20, 2015

42
src/definitions/behaviors/form.js

@ -969,10 +969,18 @@ $.fn.form.settings = {
return ($(this).filter(':checked').length > 0);
},
// value contains (text)
// value contains text (insensitive)
contains: function(value, text) {
// escape regex characters
text = text.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
return (value.search(text) !== -1);
return (value.search( new RegExp(text, 'i') ) !== -1);
},
// value contains text (case sensitive)
containsExactly: function(value, text) {
// escape regex characters
text = text.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
return (value.search( new RegExp(text) ) !== -1);
},
// is most likely an email
@ -1020,8 +1028,21 @@ $.fn.form.settings = {
);
},
// is exactly value
// is value (case insensitive)
is: function(value, text) {
text = (typeof text == 'string')
? text.toLowerCase()
: text
;
value = (typeof value == 'string')
? value.toLowerCase()
: value
;
return (value == text);
},
// is value
isExactly: function(value, text) {
return (value == text);
},
@ -1063,8 +1084,21 @@ $.fn.form.settings = {
;
},
// value is not exactly notValue
// value is not value (case insensitive)
not: function(value, notValue) {
value = (typeof value == 'string')
? value.toLowerCase()
: value
;
notValue = (typeof notValue == 'string')
? notValue.toLowerCase()
: notValue
;
return (value != notValue);
},
// value is not value (case sensitive)
notExactly: function(value, notValue) {
return (value != notValue);
},

4
src/definitions/collections/form.less

@ -240,10 +240,10 @@
white-space: nowrap;
}
.ui.form .inline.field .prompt {
margin: @validationMargin;
margin: @inlineValidationMargin;
}
.ui.form .inline.field .prompt:before {
margin-top: @validationArrowOffset;
margin-top: @inlineValidationArrowOffset;
bottom: auto;
right: auto;
top: 50%;

6
src/themes/default/collections/form.variables

@ -73,9 +73,9 @@
/* Divider */
@dividerMargin: @rowDistance 0em;
/* Validation Prompt */
@validationMargin: 0em 0em 0em @rowDistance;
@validationArrowOffset: -0.3em;
/* Inline Validation Prompt */
@inlineValidationMargin: -0.5em 0em -0.5em @rowDistance;
@inlineValidationArrowOffset: -0.3em;
/*-------------------
States

Loading…
Cancel
Save