Find us on Google+ Kill the code: validate
Showing posts with label validate. Show all posts
Showing posts with label validate. Show all posts

Monday, 12 March 2012

Count the number of Checkboxes selected

Untitled Document
Subject one two three four five

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<script type="text/javascript">
var i=0;
function isset(id) {
var n=document.getElementById(id);
if(n.checked==true) {
i++;
}
else {
i--;
}
}
function validate() {
document.getElementById('lbl').innerHTML=i+" Checkbox Selected";
}
</script>


<table width="100%"><br />
<tr>
<td width="20%">Subject </td>
<td> <input type="checkbox" id="1" onclick="return isset(this.id)" />one
<input type="checkbox" id="2" onclick="return isset(this.id)" />two
<input type="checkbox" id="3" onclick="return isset(this.id)" />three
<input type="checkbox" id="4" onclick="return isset(this.id)" />four
<input type="checkbox" id="5" onclick="return isset(this.id)" />five
</td>
<td> <input type="button" onclick="return validate()" value="Check"/> </td>
<td> <label id="lbl"> </label> </td>
</tr>
</table>

</body>
</html>


Sunday, 4 March 2012

Set Password using JAVA

//This program lets you the password and access the data as soon as you type the //correct password..without pressing ENTER...





import java.awt.*;
import java.applet.*;
import java.awt.event.*;


/*
<applet code="password_setter" width=400 height=400>
</applet>
*/


public class password_setter extends Applet implements KeyListener {
String msg="";
String password="PASSWORD";  // Write your Password here....
char c;
boolean correct=false;
int i=0;
public void init() {
addKeyListener(this);
requestFocus();
}
public void keyPressed(KeyEvent ke) {
showStatus("key Pressed.");
/*c=ke.getKeyChar();
check=true;
if(c==password.charAt(i++)) {
msg=msg+c;
}
else {
msg="";
i=0;
}*/
//if(msg.equals(password)) showStatus("VALID PASSWORD.");
//showStatus("key Pressed.");
}
public void keyReleased(KeyEvent ke) {
if(msg.equals(password)) showStatus("VALID PASSWORD.");
}
public void keyTyped(KeyEvent ke) {
showStatus("Key Typed.");
//showStatus("Key Typed.");
c=ke.getKeyChar();
if(c==password.charAt(i++)) {
msg=msg+c;
}
else {
msg="";
i=0;
}
if(msg.equals(password)) {
correct=true;
repaint();
showStatus("VALID PASSWORD.");
}
}
public void paint(Graphics g) {
if(correct) g.drawString("YOU HAVE ENTERED CORRECT PASSWORD.",40,40);
}
}