Laravel 5.7 - 自定义验证消息香菜

问题描述 投票:0回答:1

我正在开发一个系统,并在我的系统,我实现了香菜。我想更改验证消息时,某些领域不符合要求。

For example

Name Input
Description Input
Rate Input

当所有字段缺失我香菜验证工作。在我的速度输入栏我想提交表单后更改验证为“仅限十进制”。

我有现在的问题是,当我点击查看按钮模式将显示。所有的信息将在模内上市,在底部,我有编辑按钮。

当我点击编辑按钮所有标签/ P将变成输入字段(我用的jQuery这里)。

资本

<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;


    });

注:我用sweetalert的消息

问:我怎样才能改变验证消息?

jquery parsley.js parsley
1个回答
0
投票

使用data-parsley-<constraint>-message="my message"属性,其中<constraint>应该是你的约束的名称(例如required)。

© www.soinside.com 2019 - 2024. All rights reserved.