Answer the question
In order to leave comments, you need to log in
Solution for declension of nouns after numerals?
What is the best solution for declension of nouns after numerals?
I mean a way, perhaps not the most optimal, but true. Its essence is simple: We send to the function a word in the singular and a number indicating the amount. In this function, we run swtich on the last letter, and in this switch there will be 33 cases (but if the letters have the same declension, then less), in which in turn there will be 3 more cases : on the number 1, the number 2, and the number 5.
" 1 Car", "2 Cars", "5 Cars"
Answer the question
In order to leave comments, you need to log in
It is not so easy, one function is not enough, as there are many words in Russian that do not fall under the general rules.
We need a special database of words for the Russian language.
Therefore, they usually use functions that are passed words in all forms at once, and she chooses the right one according to the number.
habrahabr.ru/post/105428
www.unicode.org/cldr/charts/latest/supplemental/la...
At least it can be found in libraries supporting this
https://github.com/yaroslav/russian/blob/master/li...
In any case, the server must have your form handler. Most often it is php, due to its wide distribution.
Form validation can (and should!) be done on the client. And just duplicate it on the server. For validation, the www.formvalidator.net
plugin is very good.
Connect and configure the plugin. It will prevent you from submitting a form with errors. And when all the fields are filled in correctly, you can already send your form to the server with Ajax.
This way you can submit any form except enctype=multipart/formdata
$('[data-toggle="ajax"]').on('submit', function (e) {
e.preventDefault();
var $form = $(this);
var data = $form.serialize();
var action = $form.attr('action');
var method = $form.attr('method');
$.ajax({
url : action,
type : method,
data : data,
dataType: 'html' // или 'json' смотря какой ответ будете возвращать
}).then(function (data) {
console.log('Форма отправлена', data);
}).fail(function () {
console.log('Ошибка отправки');
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question