dongqindan4406 2010-03-02 09:24
浏览 51
已采纳

在输入元素上使用文本转换实际上会转换文本? [关闭]

Considering text-transform is a CSS property, I don't understand how the text in the input field which has text-transform set to uppercase is actually posting uppercase text to the page when the form is submitted. Isn't CSS just supposed to modify the appearance of the page and not the content itself? If I type something in lowercase in the form, shouldn't it submit in lowercase and just appear in uppercase in the form field?

I'm using PHP to process the post variables and any text that I type with text-transform set to uppercase is actually in uppercase. I modifying a value which was lowercase, the string 'This is a test.' for example... If I delete test and retype it in the input field and submit it, then print the submitted value, it will print out 'This is a TEST.' with the retyped text in uppercase and any original text in the same case as before. Is this just a glitch behavior or something?

  • 写回答

2条回答 默认 最新

  • douhuan1380 2010-03-02 13:06
    关注

    Test code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head><title></title>
    <style type="text/css"><!--
    textarea, input{
        text-transform: uppercase;
    }
    --></style>
    </head>
    <body>
    
    <?
    
    if( !empty($_POST) ){
        echo '<pre>' . htmlspecialchars(print_r($_POST, TRUE)) . '</pre>';
    }
    
    ?>
    
    
    <form action="" method="post">
        <textarea name="textarea" rows="3" cols="40">Default</textarea>
        <input name="text" value="Default">
        <input type="submit">
    </form>
    
    </body>
    </html>
    

    Interesting findings:

    • Opera 10 ignores text-transform: uppercase in textareas
    • Chrome 4 sends a GET request for the POST form
    • None of the browsers I've tested (Windows XP) feature the behaviour your describe: Firefox 3.6, IE 6, IE7, IE8, Opera 10...

    IMHO there's a great chance that you're using JavaScript...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度