Skip to main content

Posts

Showing posts from August, 2011

Simple login application using JSF

1.Login page. index.jsp. <%@pagelanguage="java"contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@taglibprefix="f"uri="http://java.sun.com/jsf/core"%> <%@taglibprefix="h"uri="http://java.sun.com/jsf/html"%> <!DOCTYPEhtmlPUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1"> <title>JSF Login Application</title> </head> <body> <f:view> <h:form> <tablestyle="width:80%;

Radio button validation using javascript.

<html>
<head>
  <script type="text/javascript">
    function radioValidation(elementID,elementName)
    {
     var selected = "";
     var radioObj = eval("document.forms[0]."+elementID);
     for(var count=0;count<radioObj.length;count++){
       if(radioObj[count].checked) {
         selected = radioObj[count].value;
         break;
       }
     }
     if(selected == ""){
        alert("Please selected your "+elementName);
        return false; 
     }
     alert("You have selected: "+selected);    
    }
  </script>
</head>
<body>
  <form>
    <input type="radio" name="sex" value="male">Male</input></br>
    <input type="radio" name="sex" value="female">FeMale</input></br>
    <input type="button" value="Check" onClick="javascript:radioValidation('se…