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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:10:03+00:00 2026-06-16T12:10:03+00:00

I am using JSF, I have an h:inputText text box, <h:form> Please enter your

  • 0

I am using JSF, I have an h:inputText text box,

<h:form>
                    Please enter your username:
                    <h:inputText value="#{user.id}"/><br/><br/>

and I wish when the user presses the submit button,

<h:commandButton value="Submit" action="upload/uploadText"/>

for it to check if there is a value entered in the input text box and that it is over 6 characters in length

how would i do this ?

code i have tried :

<script type="text/javascript"> 

        function required(){  
            if (document.getElementById("Username").value.length == 0)  
            {   
                alert("message");        
                return false;   
            }       
            return true;   
        }

    </script> 

with this :

<h:body>

                <h:form onsubmit="return required();">
                    Please enter your username:
                    <h:inputText id="Username" value="#{user.id}">
                    </h:inputText><br></br><br></br>

                    To print a piece of text, please press the submit button below to upload the text:<br/><br/>
                    <h:commandButton type="submit" value="Submit" action="upload/uploadText"/>
                </h:form>

            </h:body>

and I still am unable to get the script to run

  • 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-16T12:10:05+00:00Added an answer on June 16, 2026 at 12:10 pm

    You need to change =< to <= in the code.

    I don’t know JSF syntax, but you can try changing these three areas:

    <h:inputText name="myTextField" id="myTextField" /><br/><br/>

    <h:form onsubmit="return required();">

    function required(){  
         if (document.getElementById("myTextField").value.length <= 6)  
          {   
             alert("message");        
             return false;   
          }       
          return true;   
    }
    

    If you just need the one field validated.

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

Sidebar

Related Questions

I am using JSF 2.0 and I have text field as <h:form> <h:inputText value=#{myBean.myValue}
I have an input field taking an email address: <h:inputText value=#{register.user.email} required=true /> How
I have created webapplication using JSF 2.0 where I want to restrict user to
In JSF 2.0 have the following: Using this as a base <h:inputText id=email size=60
I am using JSF 1.2 and Richfaces 3.3.FINAL. I have an inputText which must
I am using JSF and have made a custom servlet for loading images dynamically.
i have created a demo application Using JSF & EJB 3.0 (Stateless session bean
I have a application that runs very well on JBoss using JSF 2. I
I'm using JSF 2.0. I have a managed bean which I can access through
I am using JSF and spring . I have a spring managed bean in

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.