Solved

JSP - Mandatory field

Posted on 2006-11-20
6
2,707 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
getting Http 404 error in jsp forms 8 73
constructor overloading 2 79
gZip compression filter 2 126
Reading data  from excel sheet and displaying 1 74
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
When rebooting a vCenters 6.0 and try to connect using vSphere Client we get this issue "Invalid URL: The hostname could not parsed." When we get this error we need to do some changes in the vCenter advanced settings to fix the issue.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

863 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

20 Experts available now in Live!

Get 1:1 Help Now