V
V
Vladimir Grabko2016-06-11 00:05:49
JavaScript
Vladimir Grabko, 2016-06-11 00:05:49

How to shorten code without ajax?

Here I am writing a validation

Valid.Make({
            name: "required|max:25",
            email: "required|email|max:255",
            password: "required|min:6|confirmed"
        }, {
            name: {
                required: "{{trans('validation.custom.name.required')}}",
                max: "{{trans('validation.custom.name.max')}}"
            },
            email: {
                required: "{{trans('validation.custom.email.required')}}",
                email: "{{trans('validation.custom.email.email')}}",
                max: "{{trans('validation.custom.email.max')}}"
            },
            password: {
                required: "{{trans('validation.custom.password.required')}}",
                min: "{{trans('validation.custom.password.min')}}",
                confirmed: "{{trans('validation.custom.password.confirm')}}"
            }
        }, [
            '<div class="message padd_top_10 padd_bot_10 red"><p>',
            '</p></div>'
        ], 'form1');

I'm too lazy to specify error messages for each form. Of course, you can make a route that will generate a localization json file and give it to the user, but this is an extra request and then dancing with a tambourine around localization versioning (if stored in local storage). I thought about writing a function for the template engine, but its syntax turned out to be terrible.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question