views:

32

answers:

2

Hey i am using a 3rd Party Newsletter Tool which at the end gives me the html for the form to place on my site.

Basically looks like this

<form action="http://link/subscriber/subscribe.html" method="post">
    <input name="subscribeBoxId" type="hidden" value="XXXX"/>
    <input name="subscribeBoxTitle" type="hidden" value="Subscribe Box"/>
    <input name="isExternal" type="hidden" value="true"/>
    <input name="externalPublicationId" type="hidden" value="XXXX"/>
    <b>Your details: <br /><br />
    <input name="sf_name.firstName_required" value="true" type="hidden" /><br />
...
</form>

But I Wish to add my own validation before I submit it to that form on my ASP.NET page and then submit it to that URL, how can this be achieved cheers !

+1  A: 

The easiest way is to add a function call on the clicking of the "Submit" button, something like

OnClick="return MyValidationFunction"

If you return "true" from that function, your post will occur, if you return false it will not post.

Extra detail

Per the request in comments, below is a very crude example of something that could be done. Basically you can do any validation you want. You could also do this with ASP.NET validators if you really want to, but you will need to modify the inputs to b runat="server" for them to work the best.

function MyValidationFunction()
{
   var input1 = document.getElementById('myInput');
   if (input1.value == "")
      return false
   else
      return true
}
Mitchel Sellers
Can you give an example what this MyValidationFunction Would look like, is it for example the same as RequiredFiels Validators ?
StevieB
I just added some detail though
Mitchel Sellers
A: 
jasper
Your Two options sound great, could you show an example how can I post to a link using WebRequest and pass values.
StevieB