Ho provato nella sezione javascript però mi è stato consigliato dipostarlo qui.
Dunque, ho trovato questo semplice script in ajax che permette di inviare tramite post un form. La mia domanda è come si può modificare in modo di poter inviare piu form nella stessa pagina, così:
campo1a | campo2a | campo3a ==>submit
campo1b| campo1b | campo3b ==>submit
.....
codice:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% option explicit %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%
'ASPAjax.Path="/aspajax/"
ASPAjax.Open() ' Set up ASPajax
%>
<title>ASP AJAX form processing and validation tuturial.</title>
<link href="SampleContent/CSS/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%
' Create an UpdatePanel to AJAX enable the entire form automatically.
Dim myPanel
Set myPanel = ASPAjax.CreateUpdatePanel
myPanel.Id = "VALIDATION_FORM"
myPanel.Open
Dim Message1 , Message2 , Message3
%>
<%
If Request.Form("submit")<>"" And ValidateForm() then 'process form %>
<h1> Thanks for your submission</h1>
<% else %>
<form method="post" action="">
<label for="email" >Email:</label>
<input type="text" name="email" id="email" value="<%=Request.Form("email")%>" />
<%=Message1%>
<label for="email2" >Confirm Email:</label>
<input type="text" name="email2" id="email2" value="<%=Request.Form("email2")%>"/>
<%=Message2%>
<label for="password">Password:</label>
<input type="password" name="password" id="password" value="<%=Request.Form("password")%>" />
<%=Message3%>
<input type="submit" value="Submit" name="submit" />
</form>
<% end if %>
<%
myPanel.Close 'clean up
Set myPanel = nothing
%>
Using ASP AJAX to validate forms has many advantages. </p>
In this tuturial, the form is validated at server level - yet the client has 'immediate' feedback.Form field values are not wiped on post back - reducing user frustration.</p>
</body>
</html>
<% ASPAjax.Close() ' Close up ASPajax at the end of all HTML%>
<%
Function ValidateForm
Dim Valid
If Request.Form("submit")<>"" then
Valid = true
if not isValidEmail (Request.Form("email")) then Message1 = "* Please Enter a Valid Email Address" : Valid = False
if LCASE(Request.Form("email")) <> LCASE(Request.Form("email2")) then Message2 = "* Email Addresses do not Match": Valid = False
if not isValidPassword (Request.Form("password")) then Message3 = "* Passwords should be at least 6 characters long, and contain at least 1 number.": Valid = False
End If
ValidateForm = Valid
End Function
' Helper Functions for the form
Function isValidEmail(myEmail)
dim isValidE
dim regEx
isValidE = True
set regEx = New RegExp
regEx.IgnoreCase = False
regEx.Pattern = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
isValidE = regEx.Test(myEmail)
isValidEmail = isValidE
End Function
function isValidPassword(myString)
myString = myString&""
if (Len(myString)<6) then isValidPassword = false : exit function
dim isValidE
dim regEx
isValidE = True
set regEx = New RegExp
regEx.IgnoreCase = False
regEx.Pattern = "[0-9]"
isValidE = regEx.Test(myString)
isValidPassword = isValidE
End Function
%>