dongshao1873 2017-04-06 08:38
浏览 42
已采纳

如何使文本框内容始终为大写

i want to make the value of a textbox in a form always in uppercase and i use this code

<tr>
            <td width=70>No. Polisi</td>
            <td width=10>:</td>
            <td width=30>
            <input type="text" id="nopol" type="text" name="nopol" maxlength="10" size="26" style="text-transform:uppercase" /> </td>
            <td width=1></td>
        </tr>

but when i click the submit button, the textbox that i give that code for the uppercase text. the data that i get from that textbox is change into lowercase (inside of my database)

  • 写回答

4条回答 默认 最新

  • douturan1807 2017-04-06 09:03
    关注

    In the front-end you use css to target the input type text and use text-transform to uppercase : below is a working fiddle.

    input[type="text"]{
    text-transform : uppercase
    
    }
    <form action="">
        <input type="text" id="nopol" type="text" name="nopol" maxlength="10" size="26">
    
        <input type="submit" name="submit" formmethod="POST">
    </form>

    Then in your server side use php's strtoupper() function to convert the text to uppercase

    <?php
        if(isset($_POST['submit'])){
    
                $nopol = strtoupper($_POST['nopol']);
    
    
            echo $nopol;
    
         }
    
         ?>
    
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作