移动端不允许提交emoji表情判断


<!
DOCTYPE html> <html lang="en"> <head> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" /> <meta content="telephone=no" name="format-detection" /> <title>移动端不允许提交emoji表情判断</title> <style> *{ padding:0; margin:0; } .emoji_box{ padding:10px; } textarea{ width:100%; height:100px; } input{ width:100%; height:30px; } </style> </head> <body> <div class="emoji_box"> <!-- <form action="emoji.php"> --> <textarea name="text" id="text"></textarea> <input type="submit" value="提交" id="btn"> <!-- </form> --> </div> <script type="text/javascript"> var btn = document.getElementById('btn') , text = document.getElementById('text') ; btn.onclick = function(){ var val = escape( text.value ).toLocaleLowerCase() ; if( val.match(/(\%\ue[0-9a-f]{3})|(\%\ud[0-9a-f]{3})/) ){ alert('不允许提交表情'); }else{ alert('提交') } } </script> </body> </html>

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" />
    <meta content="telephone=no" name="format-detection" />
    <title>移动端删除emoji表情</title>
<style>
*{
    padding:0;
    margin:0;
}
.emoji_box{
    padding:10px;
}    
textarea{
    width:100%;
    height:100px;
}
input{
    width:100%;
    height:30px;
}

</style>
</head>
<body>
    
    <div class="emoji_box">
        <!-- <form action="emoji.php"> -->
            <textarea name="text" id="text"></textarea>
            <input type="submit" value="提交" id="btn">
        <!-- </form> -->
    </div>

<script type="text/javascript">
    var btn = document.getElementById('btn') ,
        text = document.getElementById('text') ;

    btn.onclick = function(){

        var val = escape( text.value ).toLocaleLowerCase() ,
            unesc =  val.replace(/(\%\ue[0-9a-f]{3})|(\%\ud[0-9a-f]{3})/g , '') ,
            res = unescape( unesc );

        alert( res );
                
    }
</script>
</body>
</html>

 

posted @ 2016-05-05 11:19  Zion0707  阅读(367)  评论(0编辑  收藏  举报