JQuery removes the carriage return and jquery returns the line feed.

Source: Internet
Author: User

JQuery removes the carriage return and jquery returns the line feed.

. Replace (/[\ r \ n]/g, "") // remove the carriage return and line feed.

==================

In js, if there is a line feed js syntax, it will be considered wrong. Today, this problem is thought that the jQuery method has a limit on the length of the string or a limit on the default length of form input.

Finally, I checked for half a day and found that it was a line feed, resulting in js errors. Replace the line feed with an empty string.


The carriage return is intercepted before the JS line feed to prevent line feed from being compatible with Firefox. Do not use Jquery.

// Document. onkeydown = function (evt ){
// E = e? E: window. event;
Function keyenter (evt)

If (evt = window. event ){
If (evt. keyCode = 13)
{
Alert ("test ");
Return false;
}

}
Var keyCode = e. which? E. which: e. keyCode;
If (keyCode = 13)
{
Return doSubmit (); // call the form verification function when you press the "enter" key.
}
}
} Else //! IE
{
If (evt. which = 13)
{
Alert ("test ");
Evt. cancelBubble = true;
Evt. preventDefault ();
Evt. stopPropagation ();
}
}

Jquery shields carriage return for submission but does not block line feed

Press enter to submit. Generally, it is a trigger button event. You can judge it on the button.

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.