Validate input

Results 1 to 3 of 3

Thread: Validate input

  1. #1
    Join Date
    Dec 1969

    Default Validate input

    Hi all,<BR>I have a simple form were the users can (they dont have to) input a value.<BR>&#060;input type="text" name="HCP" size="4" maxlength="4" class="m_input"&#062;<BR>&#060;input type="image" border="0" name="OK" src="/images/ok.gif" width="34" height="18" align="bottom"&#062;<BR><BR> &#060;% if Request.form ("HCP")&#062;= 36 Then <BR> Session("HCP") = 36<BR> end if <BR> %&#062;<BR>This works fine until someone push the OK button without any value in the input field. The the following error pops up;<BR>Error Type:<BR>Microsoft VBScript runtime (0x800A000D)<BR>Type mismatch: &#039;[string: ""]&#039;<BR>/golf/golf.asp, line 476<BR>How can I;<BR>a. Tell the user they have to put in a value in order to push the button? (I don&#039;t want it to show up before the unless the button is pressed and they haven&#039;t entered a value).<BR>b. What is the value of the button when it is pressed and no value is entered into the input field ? <BR>Hope you can help me out here.<BR>Rgds,<BR>Espen<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Validate input

    Do a javascript validation on your form before submitting.<BR><BR>&#060;form name="asd"..... onSubmit="checkValues();"&#062;<BR><BR>function checkValues() {<BR> if (document.yourForm.yourinputbox.value == &#039;&#039;) {<BR> alert(&#039;enter something...&#039;);<BR> return false;<BR> } else {<BR> return true;<BR>}<BR><BR>Something like that would simply return false (ie not submitting the form) until yourinputbox contains something. There are several ways to do this with javascript.<BR><BR>As always, netscape has a great javascript reference manual wich covers everything of the javascript functions and form validations with examples.<BR><BR><BR>..a

  3. #3
    dinas Guest

    Default RE: Validate input

    use client side validation using javascript <BR>call the function when the user submits the form

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts