Field Validation Advice

Results 1 to 3 of 3

Thread: Field Validation Advice

  1. #1
    Join Date
    Dec 1969

    Default Field Validation Advice

    Ive been using ASP as well as SQL to implement my order forms and data entry into a database. Everything is working quite smooth with the exception of some field validations. My dilema is this: I have been passing form fields to the next page using the form action property where the fields are entered into the data base. I beleive these are my options for validation but I dont know enough about either to make it work. <BR>Possibility 1 <BR>I could check the field from the subsequent page where field are read using Response.Form Question 1: Does ASP allow an alert message like VB? IF so how do I return to the previous page where info was entered?<BR>Possibility 2 <BR>I could use a VBscript to validate the fields on the page that they are entered. This would probably be done with an onclick subroutine on the submit button Question: If an onclick type of subroutine is used, how is the form processed, after the onclick sub can I call the next page? How is this done?<BR><BR>These are the two possibilities that I come up with, but am open to suggestions. My expierence with VB is very limited and most of what I know is through the small amount of ASP I have done.

  2. #2
    SPG Guest

    Default RE: Field Validation Advice

    The way I do it (and I admit that I&#039m spoiled as I&#039m working on an intranet so I don&#039t have to worry about a user in Sri Lanka with a 14.4...) is to have each form submit to it&#039s own page<BR><BR>&#060;form action="&#060;%= request.serverVariables("URL") %&#062;?action=thisForm"&#062;<BR><BR>which I can pick up before I output the page<BR><BR>&#060;% if request.queryString("action") = "thisForm" then<BR> &#039 Handle the form<BR>end if %&#062;<BR><BR>Alternately, you could add the onSubmit() handler to the form<BR><BR>&#060;form action="..." onSubmit="jsValidate(this);"&#062;<BR><BR>to have JavaScript -- sorry, but if you&#039re going to do it client-side, I have to recommend a more universal language (another reason to do it on the server imho) -- run form validation. If the JavaScript routine -- jsValidate -- returns true, the form is submitted, otherwise you can use your alertboxes or whatever. I&#039d discuss this option more, but JavaScript is not my forte (given that there are at least four compiliers for each of four or more versions of four or more browsers...). has lots of JavaScript, though.

  3. #3
    Join Date
    Dec 1969

    Default RE: Field Validation Advice

    Here&#039s an example using a javascript function: <BR><BR>&#060;form method="post" action="test.asp" name="MyForm"&#062;<BR><BR>&#060;input type=text size=5 name="field1"&#062;&#060;/input&#062;<BR><BR>&#060;input type=button value="Submit" onclick="ValidateMyForm()"&#062;<BR>&#060;/form&#062;<BR> <BR><BR>function ValidateMyForm() {<BR> var flag = true<BR> field1 = document.MyForm.field1.value <BR> <BR> if (field1.length &#060; 1) {<BR> alert ("Please enter your name.")<BR> flag = false<BR> } <BR><BR> if (flag == true) {<BR> document.MyForm.submit() <BR> } <BR> <BR> }

Posting Permissions

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