First I had ValidateForm() inside the button. Now, I have put it inside the form tag. The JS code was first inside content page. Now, I've moved it js file (called FormValidator) and put reference to it inside master header. Method name is validateForm().
function validateForm() {
window.onload = function () {
etc
My js doesn't kick in now in IE. Can't see what I am doing wrong :(
Your code needs to be reafctored. Moving the JavaScript to the Master Page is the right thing. So now, remove the
onsubmit attribute from the Form tag!
dm007
Member
47 Points
106 Posts
Re: html field validation
Dec 29, 2012 05:39 PM|LINK
thanks for help!
So Inside the masterpage:
<!DOCTYPE html> <html> <%--<asp:contentplaceholder id="HeadContent" runat="server">--%> <head id="Head1" runat="server"> <title></title> <script type="text/javascript" src="js/modernizr-1.5.min.js"></script> <script src="js/FormValidation.js" type="text/javascript"></script> </head> <%-- </asp:contentplaceholder>--%> <body> <form id="Form1" onsubmit="return validateForm()" runat="server">//stuff
<script src="js/jquery.js"></script>
<script type="text/javascript" src="js/image_fade.js"></script>
</div>
</form>
Inside content
First I had ValidateForm() inside the button. Now, I have put it inside the form tag. The JS code was first inside content page. Now, I've moved it js file (called FormValidator) and put reference to it inside master header. Method name is validateForm().
function validateForm() { window.onload = function () {etc
My js doesn't kick in now in IE. Can't see what I am doing wrong :(
roopeshreddy
All-Star
20155 Points
3328 Posts
Re: html field validation
Dec 30, 2012 02:19 PM|LINK
Hi,
Your code needs to be reafctored. Moving the JavaScript to the Master Page is the right thing. So now, remove the onsubmit attribute from the Form tag!
So the code will be like this -
<!DOCTYPE html> <html> <%--<asp:contentplaceholder id="HeadContent" runat="server">--%> <head id="Head1" runat="server"> <title></title> <script type="text/javascript" src="js/modernizr-1.5.min.js"></script> <script src="js/FormValidation.js" type="text/javascript"></script> </head> <%-- </asp:contentplaceholder>--%> <body> <form id="Form1" runat="server"> //stuff <script src="js/jquery.js"></script> <script type="text/javascript" src="js/image_fade.js"></script> </div> </form> <asp:Content ID="ContactusContent1" runat="server" ContentPlaceHolderID="PageContent"> //markup <button type="submit" onclick="return validateForm();" >Send</button> </asp:Content> function validateForm() { //Your validation logic }Hope it helps u...
Roopesh Reddy C
Roopesh's Space
raju dasa
Star
14410 Points
2451 Posts
Re: html field validation
Dec 31, 2012 05:01 AM|LINK
Hi,
I think ur code should be like this:
window.onload = function () { childFunc(); } function validateForm(){ childFunc(); } function childFunc() { ... //actual code here }rajudasa.blogspot.com || blog@opera