Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Get inputText value using JavaScript

561580Mar 8 2007 — edited Mar 9 2007
Hello everyone,

I am trying to pass the value of an adf inputText to a JavaScript script for custom client validation. I am using the onclick to invoke the script upon selection of the submit button. The script is called fine when I invoke it for testing purposes by just using an alert box however as I try to read the value of the form's inputText and select the submit button nothing happens.

This is the script that I am using which is partially based on the information given in this tutorial http://www.oracle.com/technology/pub/articles/cioroianu_jsfajax.html

<afh:script>
function getFormElem(formName, elemName) {
return document.forms[formName].elements[elemName];
}

function checkUserNameValue()
{
<!-- this is the id of the f:form !-->
var formName = "createUser";
<!-- this is the id of the adf:inputText that I am trying to read the value from!-->
var elementName = "userName";
var test = getFormElem(formName,elementName).value;
alert("In the Function!");
}
</afh:script>

The onclick invokes the checkUserNameValue function which in turns invokes the getFormElem function. What am I doing wrong? If I do not comment out the part of the code where I am getting the inputText value, nothing happens upon selection of the button. It this the wrong approach to read the value on an inputText?

Any of your help will be very much appreciated.

Regards,

Sacha
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 6 2007
Added on Mar 8 2007
6 comments
926 views