JavaScript code for masking a function of JS in textarea _ form effects

Source: Internet
Author: User
There's a textarea, and I want to block a function when this focus is in this textarea,
is to make this function invalid, remove the focus and then make it effective again, how to achieve???
1 floor
In your function, you get the control of the current page focus by Document.activeelement, and you can tell if this textarea is out of the function.
2 floor
Upstairs, learning from the Meizz.
3 floor
To Meizz (Plum blossom Snow)
I was using
Document.activeElement.tagName.toLowerCase ()!= ' textarea '
To determine the textarea control, but there are multiple textarea on the page,
I just want to block this function in one of the textarea, how do I do???
More troublesome is another hidden textarea, in addition to the property is ReadOnly, other attributes and this textarea exactly the same, how to achieve?
4 floor
Using the Onfocus,onblur event as a function switch
<body>
<script language= "JavaScript" >
function Disablefun ()
{
Window.myfun = null;
}
function Enablefun ()
{
Window.myfun = function ()
{
showid.innerhtml + = "I ' m active<br>";
};
}
function Myfun ()
{
showid.innerhtml + = "I ' m active<br>";
}
</script>
<form method= "Get" name=search id=search target= "_blank" >
Triggers the Myfun function for each type of content <br>
<textarea name= "Txa" rows= "5" cols= "onkeydown=" if (myfun) myfun () "></textarea>
<br>
Each keystroke does not trigger the Myfun function (when focusing is not valid, when the focus is lost) <br>
<textarea name= "Txa" rows= "5" cols= "onfocus=" Disablefun () "onblur=" Enablefun () "onkeydown=" if (myfun) MYF Un () "></textarea>
</form>
<div id=showid>
</div>
</body>
Related Article

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.