How can set a custom message for a field?
See original GitHub issueIm already use your example code to set my message on spanish: this.validator = new SimpleReactValidator({ messages: { email: ‘That is not an email.’ // OR default: ‘Validation has failed!’ // will override all messages }, }
but Im still getting the message on english, , here’s my code:
constructor(props) {
super(props);
this.state = {
name: '',
};
this.validator = new Validator({
element: message => (
<span style={error}>
<i className="fa fa-exclamation-circle" aria-hidden="true" />
{ ` ${message}`}
</span>
),
messages: {
name: 'El campo nombre es requerido',
},
});
<div className="form-group">
<label htmlFor="name">Nombre: *</label>
<input
type="text"
name="name"
onChange={this.onChangeHandle}
className="form-control"
id="name"
placeholder="Nombre Campaña / Cupón"
/>
{this.validator.message('name', this.state.name, 'required|alpha')}
</div>
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
Personalizing Messages Using Custom Fields
Adding Custom Fields to Messages ... 1 Go to Campaigns and click New campaign. 2. Start typing out your message and click the...
Read more >Create a custom field for Outlook messages - Slipstick Systems
Create a custom field for Outlook messages · Open the View Settings dialog from the View ribbon. · Click Columns to open the...
Read more >Adding and Sending Messages with Custom Fields - YouTube
Custom fields are a perfect way to personalize your messages. You can add your own custom fields into your messages using these simple...
Read more >Is there a way to create a custom error message for one field?
From what I get from previous suggestion by our colleague, you can use the TEXT field to create your custom error message for...
Read more >How to add a custom validation message for the required field?
If you want to set one message for all the required fields across the available forms, you can use this option. Go to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I see the problem, the key for the message should be the validator rule name you want it to show on not the attribute of field (aka ‘alpha’ not 'name). For example it should look like this:
and you could do this to make it dynamic:
Let me know if you have any questions! Enjoy 👍
Oh now it’s clear. Thank you sso much.
On Thu, Oct 15, 2020 at 7:07 PM Stuart Yamartino notifications@github.com wrote: