html - External JavaScript file not working with master page -


i have external javascript file looks this:

function badcharcheck(name) { var badchar = "!@#$%^&*()_+|-=\[]{};':<>?,./";  (var = 0; < badchar.length; i++) {     (var j = 0; j < name.length; j++) {         if (badchar[i] == name[j]) {             alert("bad characters in form");             return false;          }     } }  return true; }  function samesame(pass1, pass2) { if (pass1 != pass2) {     alert("passwords not same");     return false; } return true; }  function checklength(str, length) { if (str.legnth =< length) {     alert("username must @ least 5 characters, password must @ least 8");     return false; } return true; }  function checkemail(email) {  if ((email.tostring().indexof("@") == -1) || (email.tostring().indexof(".") == -1)) {     alert("incorrect email address!");     return false; } return true; }  function validate() { document.write("here"); var ok = true; var username = document.getelementbyid("username").value; var pass1 = document.getelementbyid("pass1").value; var pass2 = document.getelementbyid("pass2").value; var fname = document.getelementbyid("firstname").value; var lname = document.getelementbyid("lastname").value; var email = document.getelementbyid("email").value;  if (fname == "" || id == "" || phone == "" || email == "" || address == "" || lname == "") {     alert("one or more of fields have been left empty!"); } else {     ok = badcharcheck(username);     ok = badcharcheck(fname);     ok = badcharcheck(lname);     ok = samesame(pass1, pass2);     ok = checklength(username, 5);     ok = checklength(pass1, 8);     ok = checkemail(email);     alert(ok);      if (ok) {         document.getelementbyid("form1").submit();         } } return false; }             

in addition have aspx file part of master page:

<%@ page title="" language="c#" masterpagefile="~/masterpage.master"     autoeventwireup="true" codefile="signup.aspx.cs" inherits="_default" %>  <asp:content id="content1" contentplaceholderid="head" runat="server"> </asp:content>  <asp:content id="content2" contentplaceholderid="contentplaceholder1" runat="server"> <h2>registration</h2> <br /> <form action="" method="post" runat="server" id="form1" name="form1" onsubmit="return validate()">     username: <input type="text" id="username" name="username" maxlength="14" /> <br />     password: <input type="password" id="pass1" name="pass1" /> <br />     re-enter password: <input type="password" id="pass2" name="pass2" /> <br />     first name: <input type="text" id="firstname" name="firstname" /> <br />     last name: <input type="text" id="lastname" name="lastname" /> <br />     email: <input type="text" id="email" name="email" /> <br />      <input type="reset" value="clean fields" />          <input type="submit" value="register" name="submit" id="submit" /> </form> 

i've added line in head tag in master page:

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

the problem javascript file not working when press submit button, if leave fields empty still submits data.

what problem?


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -