?
Solved

JSP - Mandatory field

Posted on 2006-11-20
6
Medium Priority
?
3,320 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 900 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introducing Priority Question, our latest feature.
What's worse than having your data encrypted by ransomware? Getting attacked by a so-called "wiper," which simply destroys the data and offers you no hope of ever seeing it again.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

770 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