Reputation: 1009
I am developing a system and in my system I implemented the parsley. I want to change the validation message when the certain field didn't meet the requirement.
For example
Name Input
Description Input
Rate Input
My parsley validation is working when all fields are missing. In my rate input field I want to change the validation to "Decimal Only" after submitting the form.
What I have right now is, when I clicked the view button modal will show. All the information will be listed inside of the modal, in the bottom part i have edit button.
When I clicked the edit button all the label / p will be change into input field(I used jquery here).
Modal
<form id=".." data-parsley-validate novalidate>
</form>
Jquery
Appending
$('#wht_rate_view').append('<input type="text" class="form-control" name="wht_rate" id="wht_rate" value="'+wht_rate_view+'" data-parsley-error-message="sss" required/>');
$('div').on('submit','form#update-wht-form',function(e){
var formData = $(this).serialize();
swal({
title: "Are you sure?",
text: "Once saved, you will not be able to change your key information!",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then((willSave) => {
if (willSave) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
})
$.ajax({
url: '/configurations/taxes/updateWHT',
type: "POST",
data: formData,
beforeSend: function() {
$('.update-wht').attr('disabled', 'disabled');
},
success: function(response) {
if (response != '') {
$('#get-wht-table').DataTable().destroy();
getWHTTable();
$('#update-wht-form').trigger("reset");
swal("Withholding Tax has been updated!", {
icon: "success",
});
$('#view-wht-details').modal('hide');
}
},
complete: function() {
$('.update-wht').removeAttr('disabled');
}
});
} else {
swal("Save Aborted");
}
});
e.preventDefault();
return false;
});
NOTE: I used sweetalert for the message
Question: How can I change the validation message?
Upvotes: 0
Views: 518
Reputation: 79612
Use data-parsley-<constraint>-message="my message"
attribute, where <constraint>
should be the name of your constraint (e.g required
).
Upvotes: 0