jsf - Issues with javascript not functioning and validating -


i trying use javascript validate inputs, nothing major, thought nice finishing touch jsf project

the backing bean has validation not accept inputs less 1, on 50, jsut wanted use js have use , nice give user information

i have :

<h:body>  <h:form id="myform" onsubmit="return validateform()">    <p>    number of copies (max of 50) :    <p:spinner id ="copies" min="1" max="50" value="#{printersettings.p}" size ="1">     <!-- allows user choice of 50, more enough situation, if needed can removed or raised -->    <p:ajax update="p"/>   </p:spinner>   <div class="whitespace"/>      <h:outputtext value="copies printed: &nbsp; #{printersettings.p}" id="p"/>  </p>  .............   </div>  <script type="text/javascript">   function validateform()   {    var x = document.forms["myform"]["copies"].value;    if (x === 0 || x === "")    {     alert("number of copies must greater 1 or less 51");     return false;    }   } 

but when ever submit button pressed

<p:commandbutton    type="submit"   action="#{email.mail(printersettings.t, printersettings.p, printersettings.papersize, printersettings.duplex, printersettings.orienation, printersettings.printer)}"   onclick="thankyou()"   value="print" /> 

it not validate or show javascript

what javascript trying make sure value in spinner between 1 , 50

any ideas?

edit

i have added code javascript know getting called message displays , code here still no work

            function thankyou()             {                 alert("sent printing holding queue, may close app or carry on using app, work still print out ");                 //location.href = 'index.xhtml';                 var x = document.forms["myform"]["copies"].value;                 if (x === "0" || x === "")                 {                     alert("first name must filled out");                     return false;                 }             } 

edit 2

the function being called

            function validateform()             {                 alert("test");                 var x = document.forms["myform"]["fname"].value;                 if (x === "0" || x === "")                 {                     alert("first name must filled out");                     return false;                 }             } 

but still not validating spinner :(


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -