How can I make chains, with Java or JavaScript? Help!

0

Hello Good morning to all, what happens is that I want to capitalize some chains with JavaScript, java or CSS, the latter with CSS and try with the property text-transform: capitalize; and it did not work, they only change with the other properties, by default, the application throws the result all in capital letters for example: "JUAN JOSE" and what is expected to be obtained: "Juan Jose" this is the code:

This is the method that is in charge of throwing the result in sight:

public PersonAdapter personAPersonAdapter(Person persona){
        this.setLastName( persona.getLastName());
        this.setMotherLastName( persona.getMotherLastName());
        this.setName( persona.getName() );
        this.setBirthDate( persona.getBirthDate() );
        this.setNationality( persona.getcountry().getId() );
        this.setBirthPlace( persona.getExtendedData().getBirthPlace() );//Donde se pinta DF
        this.setSex( persona.getExtendedData().getSex() ); //Aqui es donde pinta el H "O" M
        this.setCurp( persona.getIdentityDocument()[0].getNumber()  );
        return this;
    }

And in turn, this is the JSP where the result is shown:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="mbbn_mult_web_pub/css/afiNom/style.css">
<link rel="stylesheet" href="mbbn_mult_web_pub/css/afiNom/datosRegistrados.css">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<meta name="description" content="">
<meta name="author" content="XMY2147">
</head>
<body>
    <div id="titulo1" align="left">Llena los siguientes campos:</div>
    <div>
        <nav>
        <h3 align="center">Los datos que quedarán registrados son:</h3>
        <div class="content">

            <form:form commandName="persona">
                <input type="hidden" name="_flowExecutionKey"
                    value="${flowExecutionKey}" />
                <div id="contenedor">
                    <div id="contenidos">
                        <div id="columna1">
                            <label>Nombre:</label>
                        </div>
                        <div id="columna2">
                            <!-- <label>Diana Baez Dorantes</label> -->
                            <label style="text-transform: lowercase;">${persona.name} ${persona.motherLastName} ${persona.lastName}</label>
                        </div>
                    </div>
                    <div id="contenidos">
                        <div id="columna1">
                            <label>Fecha de nacimiento:</label>
                        </div>
                        <div id="columna2">
                            <!-- <label>11-03-1980</label> -->
                            <label>${persona.birthDate}</label>
                        </div>
                    </div>
                    <div id="contenidos">
                        <div id="columna1">
                            <label>Lugar de nacimiento:</label>
                        </div>
                        <div id="columna2">
                            <!-- <label>Ciudad de México</label> -->
                            <label>${persona.birthPlace}</label>
                        </div>
                    </div>
                    <div id="contenidos">
                        <div id="columna1">
                            <label>G&eacute;nero:</label>
                        </div>
                        <div id="columna2">
                            <!-- <label>Femenino</label> -->
                            <label>${persona.sex}</label>
                        </div>
                    </div>
                    <div id="contenidos">
                        <div id="columna1">
                            <label>CURP:</label>
                        </div>
                        <div id="columna2">
                            <!-- <label>BADD110313HCMLNS09</label> -->
                            <label>${persona.curp}</label>
                        </div>
                    </div>
                    <div id="contenidos">
                        <div id="columna1">
                            <label>Correo electr&oacute;nico:</label>
                        </div>
                        <div id="columna2">
                            <!-- <label>[email protected] </label> -->
                            <label>${persona.email}</label>
                        </div>
                    </div>
                    <div id="contenidos">
                        <div id="columna1">
                            <label>Teléfono celular:</label>
                        </div>
                        <div id="columna2">
                            <!-- <label>5525608650</label> -->
                            <label>${persona.telefonoCelular}</label>
                        </div>
                    </div>
                    <div id="contenidos">
                        <div id="columna1">
                            <label>Fecha de operación:</label>
                        </div>
                        <div id="columna2">
                            <label>27-02-2017</label>
                        </div>
                    </div>
                    <div id="contenidos">
                        <div id="columna1">
                            <label>Hora de operación:</label>
                        </div>
                        <div id="columna2">
                            <label>14:00:02</label>
                        </div>
                    </div>
                    <div id="candadoStyle"></div>
                </div>
                <div class="content1">
                    <div id="envioCodigo">
                        <div id="men_otp_1">
                            <p align="center">
                                Te hemos enviado un c&oacute;digo a tu celular. Tienes 5 minutos
                                para ingresarlo. Al momento de introducir el c&oacute;digo,
                                est&aacute;s aceptando que <strong>Bancomer</strong> te haga
                                llegar notificaciones al celular que acabas de proporcionar.
                            </p>
                        </div>

                        <div id="txtCodSeguridad" align="center">
                            <table>
                                <tr>
                                    <td align="right">Ingresa código de seguridad:</td>
                                    <td width="330px"><input type="text" id="inputCodSeg"></td>
                                </tr>
                            </table>
                            <div class="lblReciCod">
                                <a>No recibí codigo de seguridad</a>
                                <!-- <label class="lblReciCod">No recibí codigo de seguridad</label> -->
                            </div>
                        </div>
                    </div>
                    <br>
                </div>
                <div class="submit">
                    <input class="styleBotonCancel send" type="submit"
                        name="_eventId_cancel" value="Cancelar"> <input
                        class="styleBotonConfirm send" type="submit" name="_eventId_fin"
                        value="Confirmar">
                </div>
            </form:form>
        </div>
        </nav>
    </div>
</body>
</html>

Lastly, this is the view:

I hope and you can support me in giving me some ejm, in advance I send a cordial greeting

    
asked by JUAN JOSE BUSTAMANTE SOLIS 03.10.2017 в 17:04
source

2 answers

1

Transform them to lower all and then make a replace of the first.

var str = $(".myclass").text();
str = str.toLowerCase().replace(/\b[a-z]/g, function(letter) {
    return letter.toUpperCase();
});
$(".myclass").text(str);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="myclass">JUAN JOSE</p>
    
answered by 03.10.2017 в 17:08
1

You can achieve this by using substring , getting the first letter of string and convert it to upper case and concatenate the others:

public class StringUtils
{
    public static String captalize(String str)
    {
      return str.substring(0,1).toUpperCase() + str.substring(1).toLowerCase();
    }
 }

 StringUtils.captalize("hola mundo"); // Hola mundo
    
answered by 03.10.2017 в 17:11