Leena
Leena

Reputation: 1

problem in javascript validation , how to make call to javascript from jsf/icefaces?

problem in javascript validation , how to make call to javascript ?

<html> 
<head> 
<script type='text/javascript'> 
function validate() 
{ 
alert('hi'); 
} 
</script>
</head> 
< body> 
 <ice:panelGrid> 
 <ice:inputText/> 
..... 
... 
... 
</ice:panelGrid> 
<ice:commandButton onclick="validate();"/> 
</body> 
</html> 

I am not able to access the javascript.Getting error as validate not defined.

same if defin is onClick="alert('hi');" this alert message is working well.

So what changes should i do the invoke javascript ?

Upvotes: 0

Views: 1187

Answers (3)

Jevivre xavie
Jevivre xavie

Reputation: 303

you can use this code:

<ice:commandButton label="Click me!" onclick="if(!validate()){return false;};" />

Upvotes: 1

Bozho
Bozho

Reputation: 597114

I'd advise for double-quotes:

<script type="text/javascript"> 

Upvotes: 0

Randall Kwiatkowski
Randall Kwiatkowski

Reputation: 895

Put an end </script> tag.

<script type='text/javascript'> 
    function validate() 
    { 
        alert('hi'); 
    } 
</script>

Upvotes: 0

Related Questions