myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gerald Müllan" <bierbra...@gmail.com>
Subject Re: scripts..
Date Mon, 10 Apr 2006 16:10:51 GMT
Hi,

is it a need to do this validation on client side? How do you trigger
the js check?

If you say "nothing works", it is difficult to respond what could be
wrong. What is the exact problem?

cheers,

Gerald

On 4/10/06, sjarlier@stradefi.com <sjarlier@stradefi.com> wrote:
> Hi!
>
> I am stuck with my scripts. I would like to check if my dates are correct:
>  - The entered date is really a date
>  - The entered date is the date of the current date or a later date
>
> I am getting the date using Jenia4Faces as follow:
>
> <td colspan="2">
>    <h:outputText value="#{EFmsg.activationDate}"/>:&nbsp;&nbsp;&nbsp;
>    <h:inputText
> value="#{EF_JspWizard.jspFormEPPService.pers_activationDate}" size="10"
> id="activationDate" required="true" >
>    <f:convertDateTime pattern="dd/MM/yyyy"/>
>    </h:inputText>&nbsp;
>    <jp:popupCalendar for="activationDate" format="dd/MM/yyyy" />&nbsp;*
> </td>
>
>
> And I am testing if the date obtained is present day or late as follow:
>
> function isFutureOrPresentDate(valeur)
> {
>       var now = new Date();
>         var now_day = now.getDay();
>         var now_month = now.getMonth();
>         var now_year = now.getYear();
>
>       if(valeur.getYear()>now_year)
>             return true;
>       else if(valeur.getYear()==now_year)
>             if(valeur.getMonth()>now_month)
>                   return true;
>             else if(valeur.getMonth()==now_month)
>                   if(valeur.getDay()>now_day || valeur.getDay()==now_day)
>                         return true;
>                     else
>                         return false;
>                  else return false;
>            else
>             return false;
> }
>
>
> And I am checking if the entrance is really a date as follow:
>
> function CheckDate(d) {
>
>       // Cette fonction vérifie le format JJ/MM/AAAA saisi et la validité de
> la date.
>       // Le séparateur est défini dans la variable separateur
>
>       var amin=1900; // année mini
>       var amax=2100; // année maxi
>       var separateur="/"; // separateur entre jour/mois/annee
>       var j=(d.substring(0,2));
>       var m=(d.substring(3,5));
>       var a=(d.substring(6));
>       var ok=1;
>       if ( ((isNaN(j))||(j<1)||(j>31)) && (ok==1) ) {
>          alert("Le jour n'est pas correct."); ok=0;
>       }
>       if ( ((isNaN(m))||(m<1)||(m>12)) && (ok==1) ) {
>          alert("Le mois n'est pas correct."); ok=0;
>       }
>       if ( ((isNaN(a))||(a<amin)||(a>amax)) && (ok==1) ) {
>          alert("L'année n'est pas correcte."); ok=0;
>       }
>       if ( ((d.substring(2,3)!=separateur)||(d.substring(5,6)!=separateur))
> && (ok==1) ) {
>          alert("Les séparateurs doivent être des "+separateur); ok=0;
>       }
>       if (ok==1) {
>          var d2=new Date(a,m-1,j);
>          j2=d2.getDate();
>          m2=d2.getMonth()+1;
>          a2=d2.getFullYear();
>          if (a2<=100) {a2=1900+a2}
>          if ( (j!=j2)||(m!=m2)||(a!=a2) ) {
>             alert("La date "+d+" n'existe pas !");
>             ok=0;
>          }
>       }
>
>       return ok;
>    }
>
> And I am calling the function to check if the date is present or future date
> as follow:
>
> if(isFutureOrPresentDate(document.getElementById("person-props:activationDat
> e").value)){
>
>
> document.getElementById("person-props:activationDate").className=
> "textFields";
>
>             }
> else{
>           disabled = true;
>           document.getElementById("person-props:activationDate").className =
> "errorMessage";
>             }
>       }
>
>  But nothing works. What do I do wrong?
> Thanks in advance
> Have a nice week!
>
> Sophie
>
>
>


--
Gerald Müllan
Schelleingasse 2/11
1040 Vienna, Austria
0043 699 11772506
Bierbrauen@gmail.com

Mime
View raw message