problem in javascript validation , how to make call to javascript ?
<!DOCTYPE html>
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<html>
<head>
<script type="text/javascript">
alert('1');
function validate()
{
alert('inside function');
var str1;
// str1 = document.getElementById('name').value;
//alert(str1);
}
</script>
</head>
<body>
<ice:panelGrid columns="1" width="760px" styleClass="contentPanel">
<ice:panelGroup>
<ice:outputText value="Name"></ice:outputText>
<ice:inputText value="" id="name" ></ice:inputText>
<ice:commandButton onclick="validate();"></ice:commandButton>
</ice:panelGroup>
</ice:panelGrid>
</body>
</html>
I am not able to access the javascript.Getting error as validate not defined.
Your code seems correct, except that you have to nest all your inputText
and commandButton
components in a form:
<body>
<f:form>
<ice:panelGrid columns="1" width="760px" styleClass="contentPanel">
<ice:panelGroup>
<ice:outputText value="Name"/>
<ice:inputText value="" id="name"/>
<ice:commandButton onclick="validate();"/>
</ice:panelGroup>
</ice:panelGrid>
</f:form>
</body>