Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

JSP - Mandatory field

Posted on 2006-11-20
6
Medium Priority
?
3,672 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Industry Leaders: 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

As a matter of fact, Outlook OST files are of much importance in relation to Exchange mailbox. OST files are independent as they are simply copy of data of a user’s mailbox on Exchange Server. Though, if the server’s status is changed or it is dama…
If you need to complete a Physical to Virtual (P2V), Virtual to Virtual (V2V) conversion to a VMware product (VMware Workstation, Player or VMware vSphere (ESXi) ) for FREE, then there is some good news...
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

572 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