Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

How to pass parameter in javascript function

I want to pass one parameter to a function called ForPaste().

My function is given below:

 var regex = /^[A-Za-z0-9ĀĒĪŌŪāēīōū\.\-\~\`\'' ]*$/;
 var SalaryRegex = /^[A-Za-z0-9,円\.\/\$ ]*$/;
 $.fn.ForPaste = function () {
 return this.each(function () {
 $(this).bind('input propertychange', function () {
 var value = $(this).val();
 if (!regex.test(value)) {
 $(this).val("");
 }
 });
 });
 };

This function is in a common JS file. It is called on individual pages. I want to test the regex depending on the parameter passed. So can I know the method about to call the ForPaste() function with the parameter.e.g $("#Text1").Forpaste('FromForm1'); and I get this FromForm1 in the ForPaste() function.

Answer*

Draft saved
Draft discarded
Cancel

lang-js

AltStyle によって変換されたページ (->オリジナル) /