-
- 12 Posts
Hi. question is about "isNumber"
&myField:required:isNumber => works fine.
&myField:isNumber => keep’s geeving me an error, but the field is not required.
How to send email with "isNumber" with empty "myField" field?
-
- 5,888 Posts
I didn’t test it, but I think you need a custom-validator-snippet with something like that:
<?php
$success = $value !='' && !is_numeric($value)?false:true;
if (!$success) {
// Note how we can add an error to the field here.
$validator->addError($key,$modx->lexicon('formit.not_number'));
}
return $success;
?>
-
- 12 Posts
It’s for my multilangual site. How to put error messages from lexicon in here?
-
- 5,888 Posts
you can try
$modx->lexicon('formit.not_number')
-
- 5,888 Posts
what do mean with ’both didn’t work’ ?
what did you try?
I tried it for you and all did work.
created snippet with code above ’isEmptyOrNumber’
[[!FormIt?
&hooks=`spam,email`
&emailTpl=`myEmailChunk`
&emailTo=`[email protected]`
&customValidators=`isEmptyOrNumber`
]]
<span class="error">[[+fi.error.myfield]]</span>
</label>
<input id="myfield" name="myfield:isEmptyOrNumber" type="text" value="[[+fi.myfield]]" />
-
- 12 Posts
sorry. my bad. all works great. Thanks!