Quick question on submitting forms with ASP (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


womble -> Quick question on submitting forms with ASP (7/23/2006 15:22:43)

I have a form that I need to submit the responses to to a text file, but I also need to validate the form input. (it's for a course I'm doing). My VbScript/ASP skills are not great and I know I've not done half of it 'properly' - current strategy is to just get anything that sort of works like it should submitted (yep, Wombly in panic mode). I've done the submitting to the text file, but I'm struggling to work out how to get the validation into the same script. Then I had an idea, I'm thinking that I could do the validation script so that if all the fields validate, then it triggers the second script. Something like:

1st SCRIPT HERE
....
If Form_Valid = "false" Then
response.redirect "formpage.asp"
Else
If Form_Valid = "true" Then
response.redirect "secondscript.asp" <-- url of second script here which submits the form then redirects to the success page

Would something like that work in theory or am I way off here?




rdouglass -> RE: Quick question on submitting forms with ASP (7/23/2006 15:47:10)

quote:

I also need to validate the form input.


Is this something you can do Clientside with JavaScript?

I do that often with various Javascripts. One I change the 'action' of the form tag on the fly. What is it you hope to accomplish if the form does not validate?

Or maybe you want to do it all in ASP. If so, you may not want to bother with the redirects; you should be able to run most scripts directly if you choose:

If Form_Valid = "false" Then
'run the script directly
Else
'run the second script hereand then redirect to the success page
End If

I wish I knew more which direction you want to take this. As with most projects, there are many ways to do the little things but when you start looking at the bigger picture, some methods work better than others.




womble -> RE: Quick question on submitting forms with ASP (7/23/2006 16:38:06)

Normally I would do it client-side with JavaScript (or more usually PHP), but this has to be done in ASP (grrr!). That's a help though - thanks. [:)]




Spooky -> RE: Quick question on submitting forms with ASP (7/23/2006 16:51:57)

The typical logic I use for processing forms on the same page is this :

<%
Request all form values

If form values populated (form has been submitted) .. then
Check validation
If validation fails, do nothing
else
Submit form values to text file, redirect to success page
end if
Else
Form values not submitted, first visit
End if
%>


If validation fails, you continue to display the form page.
However, you now have the previously submitted values set as variables.
You populate the form inputs with these values and highlight the error








Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875