Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6804635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:29:26+00:00 2026-05-26T19:29:26+00:00

I have function as follows: Mask (sender) { var error= false; var regex =

  • 0

I have function as follows:

Mask (sender) { 
var error= false;
        var regex = '^[0-9]+,[0-9][0-9]$'; 
    
          if(!($(sender).val().match(regex))) {   
              error = true;
        }   
}

HTML

<input name="mf1234" value="" id="mf1234" onblur="Mask(this)"/>
<span class="comment" id="mf1234" class="sssnnn"></span>

I am calling onBlur using (this), but if I want to call it by Mask (this.id) with span id, how can I change my method code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:29:27+00:00Added an answer on May 26, 2026 at 7:29 pm
    function Mask (senderID) {
       var error= false;
        var regex = '^[0-9]+,[0-9][0-9]$'; 
    
        if(!($("#" + senderID).val().match(regex))) {   
            error = true;
        } 
    }
    

    JQuery takes the CSS selector values, so any ID’s need to be represented as #idValue
    <div id='MyId'> would be called in jQuery as $("#MyId")

    So if you plan on passing Mask(this.id) to function Mask (senderID) you need to call $("#" + senderID)

    You can call this from the HTML like so, however inline Javascript is not recommended.
    Look into Code Seperation.

    <input name="mf1234" value="" id="mf1234" onblur="Mask(this.id)"/>
    <span class="comment" id="mf1234_comment" class="sssnnn"></span>
    

    Here is the better solution…

    $(document).ready(function() {
        $("#mf1234").bind("blur", function() {
            var error = false;
            var regex = '^[0-9]+,[0-9][0-9]$';
            if (!($(this).val().match(regex))) {
                error = true;
            }
            console.log(error);
        });
    });
    

    attach your events in the javascript.. this avoids inline javascript and promotes code separation. This will aid you in Maintainability and Readability

    ohh and then you html will look like this

    <input name="mf1234" value="" id="mf1234" />
    <span class="comment" id="mf1234_comment" class="sssnnn"></span>
    

    http://jsfiddle.net/rlemon/NCwF3/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code as follows: $(#item_select).change(function() { var params = $(#item_select option:selected).val(); $.post('/account/ar_form.php', {idata:
I have a generic function for XMLHttpRequests. as follows: function XMLRequest(address, data){ this.html =
I'm currently writing an application in which I have a function as follows: var
I have a function in a native DLL defined as follows: #include <string> void
I have a DLL which provided a decoding function, as follows: function MyDecode (Source:
I have a struct as follows, with a pointer to a function called length
I have a function that is set up as follows function mainFunction() { function
If I have a jQuery plugin as follows: (function($) { $.fn.somefunction = function(text, options){
I want to have a function which gets a text as the input and
I have a function as follows: $(document).on(click, .songTilesGenreContainer, function () { if ($(this).find(.actualTilesContainer).hasClass(minimalized)) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.