It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming ASP & ASP.NET Forum

ASP.net form Validate with JavaScript help!!!

ASP.net form Validate with JavaScript help!!!

Postby vargf on Wed Sep 27, 2006 6:13 pm

Hi to all
I have to Write a method that handles the CustomerValidator's ServerValidate event. In addition, I have to write a JavaScript function for the CustomValidator's CustomValidationFunction property. Each method should verify that the user entered an integer in each text box and that the product of the integers is not a multiple of 7. Display the product of the numbers in the Label control if the numbers entered by the user satisfy the validation tests. The Java script has to be an external file
like myJscript.js

I have the following controls
Button control
two TextBox controls
Label control
CustomValidator control

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" 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 runat="server">
<title>Untitled Page</title>
<script type="text/javascript" language="javascript" src="JScript.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtinput1" runat="server" Style="z-index: 100; left: 230px; position: absolute;
top: 70px"></asp:TextBox>
<asp:TextBox ID="txtinput2" runat="server" Style="z-index: 101; left: 231px; position: absolute;
top: 122px"></asp:TextBox>
<asp:Button ID="btnCalculate" runat="server" Style="z-index: 102; left: 128px; position: absolute;
top: 93px" Text="Calculate" />
<asp:Label ID="lblAnswer" runat="server" Height="27px" Style="z-index: 103; left: 232px;
position: absolute; top: 174px" Width="153px"></asp:Label>
&nbsp;&nbsp;
<asp:CustomValidator ID="lblErrorJsInAsp" runat="server"
ControlToValidate="txtinput2" ErrorMessage="Don't devide by 0" Style="z-index: 106;
left: 260px; position: absolute; top: 177px" ClientValidationFunction="Checkinput"></asp:CustomValidator>

</div>
</form>
</body>
</html>

<-----------------External JScript code----------------------->

function Checkinput(oSrc , args)

{
alert(args.Values);
if((args.Values = % 7) == 0)
{
args.IsValid = true;
alert("Modules = 0");
}
else
{
args.IsValid = false;
alert("Module != 0");
}
}
}

The code is in ASP.net 2.0
Can any body help to me. Thanks
vargf
 
Posts: 2
Joined: Wed Sep 27, 2006 5:33 pm

Who is online

Users browsing this forum: No registered users and 1 guest