Skip to content

Commit 6960980

Browse files
committed
adding form field client-side validation.
1 parent de7bb75 commit 6960980

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ These include:
88
- a *shortcode* with which to insert a user form into any content area;
99
- a *form widget* that presents a user form (requires
1010
[silverstripe/widgets](https://github.com/silverstripe/silverstripe-widgets));
11-
- various new *form fields*.
11+
- various *additional validations* for existing form fields;
12+
- various *new form fields*.
1213

1314
## Installation
1415

@@ -43,7 +44,14 @@ You have the ability to customize display with the following options:
4344
- **Show form content?** - Chose whether to display the content of the form
4445
page.
4546
46-
## Form Fields
47+
## Additional Field Validations
48+
49+
### Maximum File Size
50+
51+
The maximum file size for a form fields will now be checked prior to submission.
52+
This is much more responsive for the user.
53+
54+
## New Form Fields
4755
4856
This module provides a selection of new field types to use with your user forms.
4957

_config/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
---
22
Name: userforms-utils
3-
---
3+
After: 'userforms/*'
4+
---
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<% require javascript('silverstripe/userforms:client/dist/js/jquery-validation/additional-methods.min.js') %>
2+
<input type="hidden" name="MAX_FILE_SIZE" value="$MaxFileSize" />
3+
<input $AttributesHTML<% if $RightTitle %> aria-describedby="{$Name}_right_title"<% end_if %>/>
4+
<script type="text/javascript">
5+
jQuery(document).ready(function() {
6+
jQuery('#{$ID}').rules('add', {maxsize: $MaxFileSize});
7+
});
8+
</script>

0 commit comments

Comments
 (0)