.

Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Wednesday, December 19, 2012

Captcha with Javascript

Here I create a Captcha Code with JavaScript.

Step 1:

In the (.aspx) page we write the following Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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 id="Head1" runat="server">
<title></title>
<script language="javascript">
var a = 49, b = 65;
var c = 100;
var d = 70;
functionshow() {
if(a == 57) {
a = 49;
}
varmain = document.getElementById('txt11');
vara1 = String.fromCharCode(a);
varb1 = String.fromCharCode(b);
varc1 = String.fromCharCode(c);
vard1 = String.fromCharCode(d);
main.value = a1 + b1 + c1 + d1;
a = a + 1;
b = b + 1;
c = c + 1;
d = d + 1;
}
</script>
<style type="text/css">
#form1
{
height: 95px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="text" id="txt11" runat="server"
style="border-style: none; border-color: inherit; border-width: medium; background-color:black; color:red; font-family: 'Curlz MT'; font-size: x-large; font-weight: bold; font-variant: normal; letter-spacing: 10pt; width: 120px; background-image: url('back.gif');"
value="4GdT" />
<input type="button" onclick="show()" value="Change" />
</div>
<asp:TextBox ID="txtverification" runat="server"></asp:TextBox>
    
<asp:Button ID="Button1" runat="server" Text="Verification"
onclick="Button1_Click" />
    
<asp:Label ID="lblmsg" runat="server" Font-Bold="True" ForeColor="Red"></asp:Label>
</form>
</body>
</html>

Step 2:

In the (.cs) page I write the following code for verification:

protected voidButton1_Click(object sender, EventArgs e)
{
if(txtverification.Text == txt11.Value)
{
lblmsg.Text = "Successful";
}
else
{
lblmsg.Text = "Failure";
}
}

Wednesday, August 26, 2009

Javascript Event List & Description

Events like performing:

  1. Click on a button
  2. Press a key
  3. Highlight text
  4. Drag & Drop

List of available javascript Events are given below:

EventDescriptionApplicable for ?
onAbortWhen user cancel image loadingImage
onBlurWhen control lost its FocusButton, Checkbox, FileUpload, Layer, Password, Radio, Reset, Select, Submit, Text, TextArea, Window
onChangeCombo index change/Textbox data changeText, TextArea, Select
onClickMost useful event. Occur when user click on a buttonButton, Checkbox, Link, Radio, Submit
onDblClickWhen user double click on a LinkLink
onFocusWhen an object get focusButton, Checkbox, Radio, Reset, Select, Submit, Text, TextArea
onKeyDownWhen the key is down means pressing timeLink, TextArea
onKeyPressWhen user presses/holds a keyLink, TextArea
onKeyUpWhen user release a keyLink, TextArea
onLoadAfter completion of loading a pageWindow, Image
onMouseDownWhen mouse pressesLink, Button, Document
onMouseMoveWhen user moves the mouseLink, Button, Document
onMouseOutWhen user moves the mouse away from a objectImage, Link
onMouseOverWhen user moves the mouse over a objectImage, Link
onMouseUpWhen user release mouseDocument, Button, Link
onMoveWhen user moves the browser window or a frameDocument, Button, Link
onResetBy clicking on reset ButtonForm
onResizeWhen user resizes the browser window or a frameWindow
onSelectWhen user select textText, TextArea
onSubmitWhen user clicks the submit buttonForm
onUnloadWhen user leaves the page/close the browserWindow

.