122 }
123 }
124
125 let url = "/client/" + input.value + "/cpf-cnpj";126 $.get(url, function(data){
127 if (data === "True") {
128 $("#cpfCnpj").addClass("is-invalid");
6 * @param input - The input element that is being validated.
7 */
8function validateLogin(input) {
9 let url = "/user/" + input.value + "/login"; 10 $.get(url, function(data){
11 if (data === "True") {
12 $("#username").addClass("is-invalid");
28 * @param input - The input element that is being validated.
29 */
30function validateEmail(input) {
31 let url = "/user/" + input.value + "/email"; 32 $.get(url, function(data){
33 if (data === "True") {
34 $("#email").addClass("is-invalid");
2$("#zip_code").change(function() {
3 let zip_code = $(this).val();
4 zip_code = zip_code.replace(/[^0-9]/, '');
5 let url = "http://localhost:8060/zipcode/" + zip_code; 6
7 if (zip_code.length !== 8) {
8 return;
8 $.get(url, function(data){
9 $("#user_id").empty();
10 $.each(data, function(i, user){
11 $("#user_id").append("<option value='" + user.id + "'>" + user.name + " " + user.last_name + "</option>");12 });
13 });
14});
In ES2015 (ES6), we can use template literals instead of string concatenation.
var str = `Hello, ${name}!`;
var str = "Hello, " + name + "!";
var str = "Time: " + (12 * 60 * 60 * 1000);
var str = "Hello World!";
var str = `Hello, ${name}!`;
var str = `Time: ${12 * 60 * 60 * 1000}`;
var str = "Hello, " + "World!";