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 976335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:43:53+00:00 2026-05-16T03:43:53+00:00

I have the following function call inside a jsp page. jQuery(function($){ $(#product).mask(99/99/9999,{placeholder: }); });

  • 0

I have the following function call inside a jsp page.

jQuery(function($){
   $("#product").mask("99/99/9999",{placeholder:" "});
});

What I want to do is pass a different string into the .mask function. In pseudo code it would look something along the lines of:

String passedParam= someString  
if(test):
  passedParam = "someotherString"

jQuery(function($){
   $("#product").mask(passedParam,{placeholder:" "});
});

Being new to both jsp and javascript I do not know the correct way to translate this pseudo code into actual working 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-16T03:43:53+00:00Added an answer on May 16, 2026 at 3:43 am

    You can use taglibs/EL in JSP to print a string as if it’s JavaScript code. You know, JSP runs at webserver machine, produces HTML/CSS/JS and sends it to the webbrowser which in turn starts to run JS code. You should write server side code accordingly that its HTML/CSS/JS output looks right when you’re doing View Source in webbrowser.

    Your pseudocode is a bit ambiguous, but I bet that you’re looking for something like this:

    jQuery(function($){
       $("#product").mask('${test ? 'someotherString' : mask}',{placeholder:" "});
    });
    

    (don’t pay attention to syntax highlighting, the code is correct, the highlighter doesn’t recognize EL)

    The ${} thing is EL (Expression Language). It will be processed when JSP runs. It should work in template text as per Servlet 2.4/JSP 2.0 (which is already over 5 years old). The ?: is the well known conditional operator. If the expression evaluates true, then the part after ? will be assigned/printed (in this case the literal string "someotherString"), otherwise the part after the : (in this case the scoped variable mask).

    This will end up in the webbrowser as

    jQuery(function($){
       $("#product").mask('someotherString',{placeholder:" "});
    });
    

    or

    jQuery(function($){
       $("#product").mask('someString',{placeholder:" "});
    });
    

    depending on the boolean outcome of test.

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

Sidebar

Related Questions

If I have the following ajax call (inside a function) how do I go
I have the following inside a function something(): if ($cod == 1000) { $message
I have a swf that opens up inside a colorbox window. When the video
I have the following code: myFunc(); bar(); myFunc() is making an ajax request I
I have two rails applications. In the first application i have the following method
I've started using the Sencha Touch / ExtJS JavaScript framework and have am noticing
what happens if the element I am binding jQuery code to is not found
I have two assemblies A & B. A has existing reference to B and
I have an approach in mind for an image viewer in a web app,
I have an div with the id article_50 . If I were to select

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.