Fake Weibo character restrictions

Source: Internet
Author: User

Er. It seems that the log has not been written for a long time .. Recently busy every day to worry about... Today, we have to empty a backup of the tips used in the project .. If you have seen it, please ignore it .. I am a front-end kitten ~~~

There is such a thing in the company's project that everyone in Weibo understands ~~

 

This is the initial status

 

The input text is like this. Here, the rounded corner is distinguished, and two halfwidth texts are regarded as one.

 

This is beyond the limit.

 

If you click Submit, a red flashing prompt is displayed.

 

Well, the effect is like this. All of them are Js .. Add a JQ file ..

Here, only the prompt is exceeded, and the extra information can be truncated later .. However, the company does not need to use projects. It means that the experience is poor ~~~

VaR oh2 = $ ("# spetit_word"); // The prompt text var otextarea = $ ("# p_qa_content "); // input box var obutton = $ ("# Bt-ICO"); // button
Otextarea. live ("keyup", function () {limit (otextarea, 280, oh2) ;}) obutton. live ("click", function () {If (font_count <0 | font_count = NULL | font_count = 140) {error (otextarea );} else {alert ('release successful! ');}});
VaR font_count; function wordlength (OBJ) {var oval = obj. val (); var ovallength = 0; oval. replace (/\ n * \ s */, '') = ''? Ovallength = 0: ovallength = oval. Match (/[^-~] /G) = NULL? Oval. Length: oval. Length + oval. Match (/[^-~] /G ). length; return ovallength} function error (OBJ) {var otimer = NULL; var I = 0; otimer = setinterval (function () {I ++; I = 5? Clearinterval (otimer): (I % 2 = 0? Obj.css ("background-color", "# ffffff"): obj.css ("background-color", "# ffd4d4") ;}, 100 );} // obj-input box to be checked, Inow-Number of words, tit-Prompt box function limit (OBJ, Inow, tit) {var ovallength = wordlength (OBJ); font_count = math. floor (Inow-ovallength)/2); If (font_count> = 0) {tit.html ("You can also enter <strong>" + font_count + "</strong>"); Return true ;} else {tit.html ("exceeds <strong style = 'color: red'>" + math. ABS (font_count) + "</strong> word"); Return false;} return font_count ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.