cancel
Showing results for 
Search instead for 
Did you mean: 

User input validation using Client Eventing

Former Member
0 Kudos

Iam developing a portal application using JSPDynpage. I need to validate a user input. I have set the input field in the jsp page as follows,

<hbj:inputField

id="custID"

type="string"

maxlength="25"

jsObjectNeeded="true">

<% custID.setClientEvent(EventTrigger.ON_CHANGE,"validate()"); %>

</hbj:inputField>

In the Javascript function,Im trying to validate a null input, as follows.

function validate(){

var funcName=htmlb_formid+"_getHtmlbElementId";

func=window[funcName];

var inputfield=eval(func("custID"));

if(inputfield){

var value=inputfield.getValue();

if(value=="")

alert("Please enter a value");

}

}

When I do this I get an error message, error in rendering jsp component.

Can anyone suggest a solution,PLEASE?

I promise to reward points

Regards,

Saraswathi

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

hi saru,

put this code it'll work

<script Language="JavaScript">

function validateInput(){

var funcName;

funcName = htmlb_formid + "_getHtmlbElementId";

func = window[funcName];

var input1 = eval(func("range_Start"));

var inputFieldValue = input1.getValue();

alert("Hi"+inputFieldValue);

}

</script>

best regards

Anagha

Former Member
0 Kudos

Hi,

Actually the code seems to work fine.

I will check with it. meanwhile try using this. I got the output with this.

<%@ taglib uri="tagLib" prefix="hbj" %>

<%@ page import="com.sapportals.htmlb.enum.EventTrigger,com.sapportals.htmlb.event.Event" %>

<hbj:content id="myContext" >

<hbj:page title="PageTitle">

<script language="Javascript">

function checkinput(){

var funcName = htmlb_formid+"_getHtmlbElementId";

func = window[funcName];

var inputfield1 = eval(func("inf1"));

var input1 = inputfield1.getValue();

if (input1==""){

alert("Enter mandatory fields");

}

}

</script>

<hbj:form>

<hbj:textView id="tv1" text="Name"/>

<hbj:inputField id="inf1"

type="String"

required="true"

jsObjectNeeded="true">

<% inf1.setClientEvent(EventTrigger.ON_BLUR, "checkinput()"); %>

</hbj:inputField>

<br>

<hbj:textView id="tv2" text="City"/>

<hbj:inputField id="inf2" type="String"/>

<hbj:button id="b1" text ="submit" onClick="onSubmitclicked"/>

</hbj:form>

</hbj:page>

</hbj:content>

Regards,

Harini S

Former Member
0 Kudos

Thank you Harini. I checked your reply to another posting and tried in a similar way. Its working fine now. Thanx again

Regards,

Saraswathi

Former Member
0 Kudos

Hi,

U have missed this.

<%@ page import="com.sapportals.htmlb.enum.EventTrigger,com.sapportals.htmlb.event.Event" %>

Regards,

Harini S

<b>Please close the thread if solved.</b>

Former Member
0 Kudos

Hi Saraswathi

Could u pls post your complete jsp?

Regards,

Padmaja