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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:47:16+00:00 2026-06-15T03:47:16+00:00

I am trying to implement java code on a web based application to reduce

  • 0

I am trying to implement java code on a web based application to reduce redundancy and increase OOP principles

I have a phone validation regular expression on server side java code. I have a requirement to perform the same validation on the browser as people are adding information, without communicating with the server. I understand I can place the same code into the javascript but then I have two locations to maintain the same code. I am looking for a simple way to send the regular expression function with the http response.

//java code
Class myVerf
{
    bool verPhone(input) {return //comepare verPhone to regEx}
}

//html
input type = "text" id = "1" onkeypress = "verPhoneFunc()"

//javascript
function verPhoneFunc()
{
    //get value from id 1
    //execute verPhone java code
}

Are there any downfalls to doing this? EX: what happens if there is no JVM on the machine the browser is running in? How does the java code execute on the browser?

I want to emphasise again… I cannot use AJAX because I can not communicate with the server.

  • 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-06-15T03:47:18+00:00Added an answer on June 15, 2026 at 3:47 am

    There’s not really a way to do what you’re looking for, without some additional technologies.

    The most direct way to do what you want is to prepare a string in some common location that both the Java and the Javascript can access it. For sake of discussion, I’ll say this is in a textfile somewhere but if you’re using (for instance) JSP, you could prepare the string in Java and publish it to Javascript via your JSP template. The string would contain the (uncompiled) regular expression.

    In this solution you have retained your main design goal (keep the regex maintained in only one place.)

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

Sidebar

Related Questions

I am trying to implement recoemmender code in java dynamic web application using direct
I am trying to implement Riot CMS to my Spring-java web application using http://www.riotfamily.org/docs/quickstart.html
I'm trying to implement java like url pattern matching in php. Suppose i have
Hi I am trying to implement the java logging in my application. I want
I'm trying to implement a generic java interface in scala. I have looked at:
I have a Java project that I'm trying to implement with a model-view-controller design.
I'm trying to implement AES in Java and this is the code I use:
I'm currently trying to implement a Java client to an SPNEGO protected web service
I am trying to implement some C code in Java by using SWIG 1.3.
I am trying to implement web browser using Swing. Here is code below. import

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.