Added basic jquery validation translations

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-07-16 20:54:48 +01:00
parent 4895023f3b
commit bb00edda4e
4 changed files with 30 additions and 18 deletions

View file

@ -155,8 +155,14 @@ return [
/*
|--------------------------------------------------------------------------
| Generic Validation Messages
| Generic Validation Messages - we use these in the jquery validation where we don't have
| access to the :attribute
|--------------------------------------------------------------------------
*/
'invalid_value_in_field' => 'Invalid value included in this field',
'generic' => [
'invalid_value_in_field' => 'Invalid value included in this field',
'required' => 'This field is required',
'email' => 'Please enter a valid email address',
],
];

View file

@ -979,7 +979,7 @@ dir="{{ Helper::determineLanguageDirection() }}">
});
// Reference: https://jqueryvalidation.org/validate/
$('#create-form').validate({
var validator = $('#create-form').validate({
ignore: 'input[type=hidden]',
errorClass: 'alert-msg',
errorElement: 'span',
@ -997,6 +997,12 @@ dir="{{ Helper::determineLanguageDirection() }}">
onfocusout: function(element) {
return $(element).valid();
},
});
$.extend($.validator.messages, {
required: "{{ trans('validation.generic.required') }}",
email: "{{ trans('validation.generic.email') }}"
});

View file

@ -11,30 +11,30 @@
@include ('partials.forms.edit.category-select', ['translated_name' => trans('admin/categories/general.category_name'), 'fieldname' => 'category_id', 'required' => 'true', 'category_type' => 'license'])
<!-- Serial-->
@can('viewKeys', $item)
<div class="form-group {{ $errors->has('serial') ? ' has-error' : '' }}">
<label for="serial" class="col-md-3 control-label">{{ trans('admin/licenses/form.license_key') }}</label>
<div class="col-md-7{{ (Helper::checkIfRequired($item, 'serial')) ? ' required' : '' }}">
<textarea class="form-control" type="text" name="serial" id="serial">{{ old('serial', $item->serial) }}</textarea>
{!! $errors->first('serial', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
@endcan
<!-- Seats -->
<div class="form-group {{ $errors->has('seats') ? ' has-error' : '' }}">
<label for="seats" class="col-md-3 control-label">{{ trans('admin/licenses/form.seats') }}</label>
<div class="col-md-7 col-sm-12 required">
<div class="col-md-2" style="padding-left:0px">
<input class="form-control" type="text" name="seats" id="seats" value="{{ old('seats', $item->seats) }}" />
<div class="col-md-12" style="padding-left:0px">
<input class="form-control" type="text" name="seats" id="seats" value="{{ old('seats', $item->seats) }}" minlength="1" required style="width: 97px;">
</div>
</div>
{!! $errors->first('seats', '<div class="col-md-8 col-md-offset-3"><span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span></div>') !!}
</div>
@include ('partials.forms.edit.minimum_quantity')
<!-- Serial-->
@can('viewKeys', $item)
<div class="form-group {{ $errors->has('serial') ? ' has-error' : '' }}">
<label for="serial" class="col-md-3 control-label">{{ trans('admin/licenses/form.license_key') }}</label>
<div class="col-md-7{{ (Helper::checkIfRequired($item, 'serial')) ? ' required' : '' }}">
<textarea class="form-control" type="text" name="serial" id="serial">{{ old('serial', $item->serial) }}</textarea>
{!! $errors->first('serial', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
@endcan
@include ('partials.forms.edit.company-select', ['translated_name' => trans('general.company'), 'fieldname' => 'company_id'])
@include ('partials.forms.edit.manufacturer-select', ['translated_name' => trans('general.manufacturer'), 'fieldname' => 'manufacturer_id',])
@ -51,7 +51,7 @@
<div class="form-group {{ $errors->has('license_email') ? ' has-error' : '' }}">
<label for="license_email" class="col-md-3 control-label">{{ trans('admin/licenses/form.to_email') }}</label>
<div class="col-md-7">
<input class="form-control" type="text" name="license_email" id="license_email" value="{{ old('license_email', $item->license_email) }}" />
<input class="form-control" type="email" name="license_email" id="license_email" value="{{ old('license_email', $item->license_email) }}" />
{!! $errors->first('license_email', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>

View file

@ -106,7 +106,7 @@
</label>
@if ($errors->has('pwd_secure_complexity.*'))
<span class="alert-msg">{{ trans('validation.invalid_value_in_field') }}</span>
<span class="alert-msg">{{ trans('validation.generic.invalid_value_in_field') }}</span>
@endif
<p class="help-block">
{{ trans('admin/settings/general.pwd_secure_complexity_help') }}