You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Form validation requires passing in a validation object with the rules required to validate your form.</p>
30
30
<div class="ui ignored info message">
31
-
A validation object includes a list of form elements, and rules to validate each against. Fields are matched by either the <code>id</code> tag, <code>name</code> tag, or the <code>data-validate</code> metadata matching the identifier provided in the settings object.
31
+
A validation object includes a list of form elements, and rules to validate each field against. Fields are matched by either the <code>id</code>, <code>name</code>, or <code>data-validate</code> property matching the identifier specified in the settings object.
prompt : 'Your password must be at least 6 characters'
97
+
prompt : 'Your password must be at least {ruleValue} characters'
83
98
}
84
99
]
85
100
},
86
101
terms: {
87
-
identifier: 'terms',
102
+
identifier: 'terms',
88
103
rules: [
89
104
{
90
105
type : 'checked',
@@ -146,6 +161,102 @@ type : 'UI Behavior'
146
161
</div>
147
162
</form>
148
163
164
+
<div class="prompt example">
165
+
<h4 class="ui header">Customizing Prompts</h4>
166
+
<p>Form validation includes default error prompts for most cases, however these can be quite generic. To specify custom personalized values for a validation prompt use the <code>prompt</code> property with a rule.</p>
167
+
<div class="ui ignored info message">You can set default messages for each validation rule type by modifying <code>$fn.form.settings.prompt</code></div>
168
+
<p>Prompt also supports custom templating with the following values replaced</p>
<td>The current text of a field's label, or if no label available its placeholder text</td>
174
+
</tr>
175
+
<tr>
176
+
<td class="four wide"><b>{identifier}</b></td>
177
+
<td>The identifier used to match the field</td>
178
+
</tr>
179
+
<tr>
180
+
<td class="four wide"><b>{value}</b></td>
181
+
<td>The current field value</td>
182
+
</tr>
183
+
<tr>
184
+
<td class="four wide"><b>{ruleValue}</b></td>
185
+
<td>The value passed to a rule, for example <code>minLength[100]</code> would set this value to 100</td>
186
+
</tr>
187
+
</tbody>
188
+
</table>
189
+
<div class="ignored code">
190
+
$('.ui.form')
191
+
.form({
192
+
fields: {
193
+
field1: {
194
+
rules: [
195
+
{
196
+
type : 'empty'
197
+
}
198
+
]
199
+
},
200
+
field2: {
201
+
rules: [
202
+
{
203
+
type : 'exactly[dog]',
204
+
prompt : '{name} is set to "{value}" that is totally wrong. It should be {ruleValue}'
205
+
}
206
+
]
207
+
}
208
+
}
209
+
})
210
+
;
211
+
</div>
212
+
<form class="ui form segment">
213
+
<div class="two fields">
214
+
<div class="field">
215
+
<label>Field 1</label>
216
+
<input type="text" name="field1">
217
+
</div>
218
+
<div class="field">
219
+
<label>Field 2</label>
220
+
<input type="text" name="field2">
221
+
</div>
222
+
</div>
223
+
<div class="ui blue submit button">Submit</div>
224
+
<div class="ui error message">
225
+
</div>
226
+
</form>
227
+
</div>
228
+
229
+
<div class="matching example">
230
+
<h4 class="ui header">Matching Fields</h4>
231
+
<p>By default the property name used in the validation object will match against the <code>id</code>, <code>name</code>, or <code>data-validate</code> property of each input to find the corresponding field to match validation rules against.</p>
232
+
<p>If you need to specify a different identifier you can use the <code>identifier</code> property on each validation rule</p>
0 commit comments