Solved

JSP - Mandatory field

Posted on 2006-11-20
6
2,638 Views
Last Modified: 2012-05-05
I need to create a simple page in which contains the user name and email address.

Both fields have * next to label which indicates the field must be entered.

If the Submit button is selected, I need to make sure those field must be provided, If not, a error message is displayed, stating that field must be provided.

I know how to do in JSF using JDeveloper 10g.

But we are using SAP AS it doesnt support the JSF features.

Please advise.
0
Comment
Question by:LeanMoreTryMore
  • 4
  • 2
6 Comments
 
LVL 10

Expert Comment

by:jaggernat
ID: 17984281
does SAP AS  support struts api. you can use the struts validation framework if you want to validate the two fields server side.
If there is no support for struts api, you can use javascript validation for client side validation
something like..
function validate
{
if(document.forms[0].username.value == "")
{
alert("Please enter a valid Username");
}
//similarly for email address
0
 

Author Comment

by:LeanMoreTryMore
ID: 17990243
Anything goes to SAP is very strange, i am not sure whether it support struts api.

as this is quite urgent, the quick fix may be used java script.

How do i invoke the above java script where the SUBMIT button is clicked ?
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17991897
function submitAction()
{
if(document.forms[0].username.value == "") {
alert("Please enter a valid Username");
}
if(document.forms[0].email.value == "")
{
alert("Please enter a valid Email");
}
}

//username and email are the field name

<input type="button" name="" value="Submit" onclick="submitAction();">
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:LeanMoreTryMore
ID: 17992173
Thanks.

Yes. it does pop up the alert message. Where the OK button is clicked it calls the next page. I want to stop if the required field is blank. Please advise

the following is the  the form use post to the next page

<form name="wizard" method="POST" action="/ServiceRequest">
0
 
LVL 10

Accepted Solution

by:
jaggernat earned 300 total points
ID: 17992204
try this


function submitAction()
{
if(document.forms[0].username.value == "") {
alert("Please enter a valid Username");
return false;
}
if(document.forms[0].email.value == "")
{
alert("Please enter a valid Email");
return false;
}
}
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 18000357
if the solution fully solved your problem, you are supposed to give an "A".
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Hyena v12.2 is now available for downloading and is available in English, French, German and Spanish versions.
In  today’s increasingly digital world, managed service providers (MSPs) fight for their customers’ attention, looking for ways to make them stay and purchase more services. One way to encourage that behavior is to develop a dependable brand of prod…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now