cancel
Showing results for 
Search instead for 
Did you mean: 

HTMLB:inputField and events.

Former Member
0 Kudos

Hello,

In plain HTML, the validation of an entry can be done with something like this :


<input type="text" id="t1" onKeyUp="alert(document.form1.t1.value)">

With htmlb:inputField however, I find nothing that can trigger an event when the user enters data.

Is there any way of validating the data that a user enters with the htmlb:inputField ?

Thanks in advance,

Dirk.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

i would solve this by java script.

<u>for example:</u>

<script type="text/javascript">

window.captureEvents(Event.KEYPRESS);

window.onkeypress = myfunction;

function myfunction (event) {

.... your function ....

}

</script>

Answers (2)

Answers (2)

Former Member
0 Kudos

Problem solved :

With the following code :


<%
foostr = `<input onKeyUp="alert('validate')"`.
%>
<bsp:findAndReplace find    = "<input"
                    replace = "<%= foostr %>" >

the datastream can be influenced.

Thx Raja.

Former Member
0 Kudos

Better use event onChange (only validate if the value of the your input change)

Bye

Former Member
0 Kudos

HI,

You have two options ,

You can use the attributes of the input filed

<htmlb:inputField id = ip1

doValidate="TRUE"

required="TRUE">

Else , you can write your own javascript which can be triggered on button click for form data validation :

In the head

function ValidateForm()

{

var = document.getElementById("ip1");

if(var.value)

alert("you have entered "+ var);

return false;

}

where ip1 is the id of the input field.

Button is

<htmlb:button id="but1"

width="20"

onClick="myEvent"

onClientClick="if(!ValidateForm(this))htmlbevent.cancelSubmit=true;"

text="Submit"/>

HOpe this helps,

Regards,

Siddhartha

Former Member
0 Kudos

Hello Siddhartha,

Thanks for the response,

Option 1 :

I can type the attribute doValidate in my coding, but it seems to do nothing ?

In the F1-help the word doValidate isn't present ??

We run WAS 6.20 SP 52.

Option 2 :

Is not an option because I want to validate the moment the user types something, not when the user clicks a button.

Regards,

Dirk.