on 11-15-2007 4:21 PM
Hi All,
How can we validate an input field in a form in BSP page.
Like: There are two input fields in my form.I want the user to enter value in any one and only one of the fields.If the value is entered in both fields or none of the fields the user should get a popup and form must not be submited.
Shall i use the onClientClick attribute of Button element or doValidate attribute of Inputfield element or validationScript attribute of From element?
Please help.
Thanks a lot,
Anubhav.
Here you go:
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
<htmlb:page title=" " >
<htmlb:form id="form1" >
< script t-ype = "text/javascript" > "Remove "-" between t & ype in type
function checkInput()
{
var field1 = document.form1.field1.value;
var field2 = document.form1.field2.value;
var error = "";
if(field1 != "" && field2 != "")
{ error = "X";
javascript error message here }
if(field1 == "" && field2 == "")
{ error = "X";
javascript error message here
}
if(error == "")
{
htmlbSL(this,2,'mybutton:Submit');
}
}
< / script >
<htmlb:textView text = "Hello World!"
textColor = "RED"
design = "HEADER1"
align = "CENTER" />
<htmlb:inputField id = "field1"
value = "<%= var1 %>"
type = "integer"
alignment = "CENTER" />
<htmlb:inputField id = "field2"
value = "<%= var2 %>"
type = "integer"
alignment = "CENTER" />
<htmlb:button id = "mybutton"
text = "Press Me"
onClientClick = "javascript:checkInput();" />
</htmlb:form>
</htmlb:page>
</htmlb:content>
Raja T
Message was edited by:
Raja Thangamani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Replace "javascript error message here" with alert meesage. This editor is not allowing me to post Javascript code.
Raja T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.