NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Visual Web JSF Page and JavaScript

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
yahya_ganzoury



Joined: 27 Sep 2009
Posts: 1

PostPosted: Sun Sep 27, 2009 12:59 pm    Post subject: Visual Web JSF Page and JavaScript Reply with quote

Peace be upon you,
I am developing web application using JSF.
In the register form I use client side javascript function to check the matching between the password and the Password confirmation field.
But this code does not work although the function is called and an alert message appears as a test.

the JSF page:
Code:

<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
    <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view>
        <webuijsf:page id="page1">
            <webuijsf:html id="html1">
                <webuijsf:head id="head1">
                    <webuijsf:link id="link1" url="/resources/stylesheet.css"/>
                    <webuijsf:script id="script1" url="/resources/test.js"/>
                </webuijsf:head>
                <webuijsf:body id="body1" style="-rave-layout: grid">
                    <webuijsf:form id="registerForm">
                        <webuijsf:textField id="userName" style="left: 288px; top: 48px; position: absolute"/>
                        <webuijsf:label id="lbl_user_Name" style="left: 120px; top: 48px; position: absolute" text="#{msgs.namePrompt}"/>
                        <webuijsf:label id="lbl_password" style="position: absolute; left: 120px; top: 96px" text="#{msgs.passwordPrompt}"/>
                        <webuijsf:label id="lbl_confirmed_password" style="left: 120px; top: 144px; position: absolute" text="#{msgs.confirmPasswordPrompt}"/>
                        <webuijsf:passwordField id="password" style="left: 288px; top: 96px; position: absolute"/>
                        <webuijsf:passwordField id="passwordConfirm" style="left: 288px; top: 144px; position: absolute"/>
                        <webuijsf:button id="submit" onClick="checkPassword(this.form)" style="left: 167px; top: 192px; position: absolute" text="#{msgs.submit}"/>
                    </webuijsf:form>
                </webuijsf:body>
            </webuijsf:html>
        </webuijsf:page>
    </f:view>
</jsp:root>


the Java Script file:
Code:
function checkPassword(form) {
    alert("test");
   var password =form["registerForm:password"].value;
    var passwordConfirm = form["registerForm:passwordConfirm"].value;
    if(password == passwordConfirm)
        form.submit();
    else
        alert("Password and password confirm fields don't match")
}


Any suggestions,
Thanks in advance
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo