validating input boxes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MadMike42

    validating input boxes

    This is really starting to annoy me,
    I've got a form, that has some input boxes,
    a example of the code is here:-

    <form action="admin_s ave_stock.asp" method="post" name="MyFormDat a">
    <input name="Make" type="text" id="MenuText" value=<% response.write
    rsTable("Make") %size="50" maxlength="50">
    <input name="DateBough t" id="MenuText" type="text" value=<% response.write
    rsTable("DateBo ught") % size="10" maxlength="10">
    </form>

    I also have a FUNCTION that checks to make sure the dates etc are correct :-
    But, the code will work as far as giving me the error MSGBOX
    but it still posts to the next page for some reason its
    ignoring the " MyFormData_OnSu bmit = False "

    Why ?

    <Script language="vbscr ipt">
    Function MyFormData_OnSu bmit()
    Dim FormOkay

    FormOkay=True

    if isdate(MyFormDa ta.DateBought.V alue)=False then
    msgbox "Error in date", vbokayonly+vbin formation,"Chec king Data"
    MyFormData.Date Bought.SetFocus
    FormOkay=False
    end if

    if FormOkay=False then
    MyFormData_OnSu bmit = False
    else
    MyFormData_OnSu bmit = True
    end if

    end Function
    </Script>

    thankls
    Mike.


  • Jon Paal

    #2
    Re: validating input boxes

    I don't think there is a "setfocus"

    try this
    =============== ==============

    <Script language="vbscr ipt">

    Function validate()

    Dim FormOkay
    FormOkay=True
    Set TheForm = Document.forms( "MyFormData ")

    if isdate(TheForm. DateBought.Valu e)=False then
    msgbox "Error in date", vbokayonly+vbin formation,"Chec king Data"
    end if

    end Function
    </Script>

    <form action="admin_s ave_stock.asp" method="post" name="MyFormDat a" id="MyFormData " onsubmit="valid ate(); return false;"
    language="jscri pt">
    <input name="Make" id="Make" type="text" value="<%= rsTable("Make") %>" size="50" maxlength="50">
    <input name="DateBough t" id="DateBought " type="text" value="<%= rsTable("DateBo ught") %>" size="10" maxlength="10">
    <input name="Submit" TYPE="Submit" VALUE="Submit">

    </form>




    "MadMike42" <mike42@ntlworl d.comwrote in message news:yKR0h.1353 5$76.12222@news fe5-win.ntli.net...
    This is really starting to annoy me,
    I've got a form, that has some input boxes,
    a example of the code is here:-
    >
    <form action="admin_s ave_stock.asp" method="post" name="MyFormDat a">
    <input name="Make" type="text" id="MenuText" value=<% response.write rsTable("Make") %size="50" maxlength="50">
    <input name="DateBough t" id="MenuText" type="text" value=<% response.write rsTable("DateBo ught") % size="10" maxlength="10">
    </form>
    >
    I also have a FUNCTION that checks to make sure the dates etc are correct :-
    But, the code will work as far as giving me the error MSGBOX
    but it still posts to the next page for some reason its
    ignoring the " MyFormData_OnSu bmit = False "
    >
    Why ?
    >
    <Script language="vbscr ipt">
    Function MyFormData_OnSu bmit()
    Dim FormOkay
    >
    FormOkay=True
    >
    if isdate(MyFormDa ta.DateBought.V alue)=False then
    msgbox "Error in date", vbokayonly+vbin formation,"Chec king Data"
    MyFormData.Date Bought.SetFocus
    FormOkay=False
    end if
    >
    if FormOkay=False then
    MyFormData_OnSu bmit = False
    else
    MyFormData_OnSu bmit = True
    end if
    >
    end Function
    </Script>
    >
    thankls
    Mike.
    >
    >

    Comment

    • MadMike42

      #3
      Re: validating input boxes

      That's it !

      I changed from .SetFocus to just .Focus and it worked
      many thanks
      Mike.


      "Jon Paal" <Jon nospam Paal @ everywhere dot comwrote in message
      news:12k85e4t06 sdp55@corp.supe rnews.com...
      >I don't think there is a "setfocus"
      >
      try this
      =============== ==============
      >
      <Script language="vbscr ipt">
      >
      Function validate()
      >
      Dim FormOkay
      FormOkay=True
      Set TheForm = Document.forms( "MyFormData ")
      >
      if isdate(TheForm. DateBought.Valu e)=False then
      msgbox "Error in date", vbokayonly+vbin formation,"Chec king Data"
      end if
      >
      end Function
      </Script>
      >
      <form action="admin_s ave_stock.asp" method="post" name="MyFormDat a"
      id="MyFormData " onsubmit="valid ate(); return false;" language="jscri pt">
      <input name="Make" id="Make" type="text" value="<%= rsTable("Make") %>"
      size="50" maxlength="50">
      <input name="DateBough t" id="DateBought " type="text" value="<%=
      rsTable("DateBo ught") %>" size="10" maxlength="10">
      <input name="Submit" TYPE="Submit" VALUE="Submit">
      >
      </form>
      >
      >
      >
      >
      "MadMike42" <mike42@ntlworl d.comwrote in message
      news:yKR0h.1353 5$76.12222@news fe5-win.ntli.net...
      >This is really starting to annoy me,
      >I've got a form, that has some input boxes,
      >a example of the code is here:-
      >>
      ><form action="admin_s ave_stock.asp" method="post" name="MyFormDat a">
      ><input name="Make" type="text" id="MenuText" value=<% response.write
      >rsTable("Make" ) %size="50" maxlength="50">
      ><input name="DateBough t" id="MenuText" type="text" value=<%
      >response.wri te rsTable("DateBo ught") % size="10" maxlength="10">
      ></form>
      >>
      >I also have a FUNCTION that checks to make sure the dates etc are correct
      >:-
      >But, the code will work as far as giving me the error MSGBOX
      >but it still posts to the next page for some reason its
      >ignoring the " MyFormData_OnSu bmit = False "
      >>
      >Why ?
      >>
      ><Script language="vbscr ipt">
      >Function MyFormData_OnSu bmit()
      >Dim FormOkay
      >>
      >FormOkay=Tru e
      >>
      >if isdate(MyFormDa ta.DateBought.V alue)=False then
      > msgbox "Error in date", vbokayonly+vbin formation,"Chec king Data"
      > MyFormData.Date Bought.SetFocus
      > FormOkay=False
      >end if
      >>
      >if FormOkay=False then
      > MyFormData_OnSu bmit = False
      >else
      > MyFormData_OnSu bmit = True
      >end if
      >>
      >end Function
      ></Script>
      >>
      >thankls
      >Mike.
      >>
      >>
      >
      >

      Comment

      Working...