473,387 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

javascript function for customvalidator

I am trying to use a Custom Validator linked to a javascript function for a textbox for the first time. All my code is on one page (inline script). I apparently have made some errors, and I am hoping someone can help me.

Here is a example of how i am doing it now:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <script runat="server">
  3.   Sub Page_Load(sender As System.Object, e As System.EventArgs)
  4.   End Sub
  5.   Sub onclick1(sender As System.Object, e As System.EventArgs)
  6.     if Page.IsValid then
  7.       results.InnerHtml="Data is Valid Test"
  8.     end if
  9.   End Sub
  10. </script>
  11. <html><head>
  12. <script type="text/javascript">
  13. <!--
  14. function go(source,args)
  15. {
  16.   boxVal=document.getElementById('<%=box.ClientID%>').value;
  17.   boxVal2=document.getElementById('<%=box2.ClientID%>').value;
  18.  
  19. //DATA TESTS RAN HERE
  20.   if (validData!=true)
  21.   {
  22.     document.jvform.errorArea.value=errorC;//errorC would just be a string describing errors made
  23.     return false;
  24.   }
  25.   else
  26.   {return true;}
  27. }//END FUNCTION
  28. -->
  29. </script></head>
  30. <body>
  31. <form name='jvform' method='post' runat='server'>
  32.   <asp:TextBox id="box" MaxLength="4" columns="4" Runat="server"></asp:TextBox>
  33.   <asp:TextBox id="box2" MaxLength="4" columns="4" Runat="server"></asp:TextBox>
  34.   <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Error in Feild(s)." ClientValidationFunction="go" ValidateEmptyText="True"></asp:CustomValidator>
  35.   <textarea id='errorArea'></textArea>
  36.   <div id='results' runat='server'></div>
  37.   <asp:Button id="send1" onclick="onclick1" Runat="server" Text="Validate"></asp:Button>
  38. </form>
  39. </body></html>
  40.  
*the problem is that my data keeps getting sent to the server even tho it is invalid, and the error string that gets put into 'errorArea' gets pulled out when the sever sends back its response
Jul 28 '12 #1

✓ answered by str4nge

nevermind. i changed it to args.IsValid instead of return, and it works.

1 1559
nevermind. i changed it to args.IsValid instead of return, and it works.
Jul 28 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Patrice | last post by:
Hi, I'm trying to use a javascript function passing a vb variable. I don't understand why it doesn't work. Can someone help me? Thanks in advance. Here is my javascript function used to...
1
by: Obscurr | last post by:
i've got an array created in php that I want to send over to a javascript function. onclick = "return sjekk(<?echo $names; ?> )" in my "sjekk" function, when I try to print an alert : ...
5
by: elsenraat_76 | last post by:
Hello! I was wondering if someone could help me out with a problem I'm having? I'm trying to input a javascript value into an anchor tag (from a function), but don't have an event to call the...
0
by: Prescott | last post by:
I want to execute a javascript function that will set a value in the parent window from the child widow where its called and then post the form to the server. I seem to be able to execute one or...
4
by: Martin Feuersteiner | last post by:
Dear Group I'm using VB to write an aspnet application. I would like to call a javascript function from within a VB Sub or VB Function, is it possible? My code is something like this: VB...
1
by: avp | last post by:
Hi, We have an ASP.NET 2.0 (C#) application that has a web form with a CheckBoxList control and a CustomValidator control. The CustomValidator control is used to validate that at least one...
1
by: cemcat | last post by:
Hello, We have an ASP.NET 2.0 (C#) web form that contains a textbox for users to enter multiple e-mail addresses separated by semicolons. We need to validate that each individual e-mail address...
18
by: Chris Ianson | last post by:
Hi geniuses (or is that genii, or genies) The challenge is as above really. I have a page with an iframe in it, and need to call a JS function in the *parent* page, *from* inside the iframe. ...
6
by: Ajit Goel | last post by:
Hi; We have a Javascript function which I have been tasked to move to a CSharp class. This javascript function uses Regular expression extensively. This function has a string input parameter and...
10
by: evicailieva | last post by:
A have a php scrip where I call a JavaScript function. I don't know why, but it doesn't work. At the beginning, when I was writing the script it was working but now it's not. I don't know wхat to do....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.