473,322 Members | 1,421 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,322 software developers and data experts.

Custom validation not working when Javascript moved to external file

Hello,

I am writing a page that makes use of a lot of custom validators. So
far, all the custom client-side validation code has been added in the
<head> tag of the page, but I decided to move it out to an external file
to keep this file cleaner. Trouble is that it now doesn't get called at
all.

I have the following line in the <head> of the page...

<script language="javascript" type="text/javascript" src="validation.js"></script>

I know the reference is right as a) the file is there and b) VWD gave me
the file name in a drop-down when I typed the "src" attribute. Despite
this, the code in there just doesn't get called. It works fine when the
code is inline in the page itself.

Anyone any ideas? TIA

--
Alan Silver
(anything added below this line is nothing to do with me)
Jun 20 '06 #1
1 1811
In article <vo**************@nospamthankyou.spam>, Alan Silver
<al*********@nospam.thanx.invalid> writes
<snip>
Anyone any ideas? TIA


I have!! I found out the problem, it was due to the way I was getting
element names in the Javascript. As I am using Master pages, the IDs of
the elements is not known at design time, so I have to do something
like...

myvalue = document.forms[0].<%= txtCustomerNumber.ClientID %>.value;

which works fine when the Javascript is in the .aspx file, but (rather
obviously) fails when it is moved into an external .js file.

So, it looks like this can't be done. Anyone any ideas? TIA

--
Alan Silver
(anything added below this line is nothing to do with me)
Jun 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Arun K | last post by:
Hi, I am creating a simple .aspx page to add some fields with validation. I have used different .NET validations like REquiredFieldValidator, RegularExpressionValidator and showed the summary...
2
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow...
1
by: shajutc | last post by:
I have created a new site, using asp.net c#. My pages contain client side validation to validate the users input. On my local machine this works fine, but when I moved my site to the test server,...
1
by: Dennis Calla | last post by:
I recently moved my app to a hosted environment and the validation stopped working (i had it on my own webserver). I put an alert in the validation javascript file so I know it is being called. ...
5
by: | last post by:
Hi all, Has anyone been able to write some custom javascript on the onclick event of submit button to do certain things like disable submit button, only submit form once etc. This was a breeze...
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
1
by: rn5a | last post by:
I have created a custom control button which when clicked displays a message in the JavaScript alert dialog. I could successfully compile the VB class file into a DLL & also could add it to the...
0
by: rn5a | last post by:
A custom control is derived from the WebControl class & encapsulates a TextBox & a Button. When the Button is clicked, the user is shown the JavaScript confirm dialog with the 'OK' & 'Cancel'...
3
by: matko | last post by:
This is a long one, so I'll summarize: 1. What are your opinions on raising an exception within the constructor of a (custom) exception? 2. How do -you- validate arguments in your own...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.