function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Yash SadeghiYash Sadeghi 

My web-to-lead html form won't work on visualforce, it keeps giving me errors, any suggestions ?

Whenever I'm trying saving this into my visualforce page it won't let me based on erros, even when I correct them it won't stop there. I'd appreciate any kind of help.

This is the we-to-lead form

<apex:page >
<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">

<input type="hidden name"="oid" value="00D58000000bQkZ">
<input type="hidden name"="retURL" value="http://cognizant-interest.com/form">

<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: These fields are optional debugging elements. Please uncomment    -->
<!--  these lines if you wish to test in debug mode.                          -->
<!--  <input type="hidden" name="debug" value=1>                              -->
<!--  <input type="hidden" name="debugEmail"                                  -->
<!--  value="yashar.sadeghi@cognizant.com">                                   -->
<!--  ----------------------------------------------------------------------  -->

<label for="first_name">First Name</label><input  id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>

<label for="last_name">Last Name</label><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>

<label for="email">Email</label><input  id="email" maxlength="80" name="email" size="20" type="text" /><br>

<label for="phone">Phone</label><input  id="phone" maxlength="40" name="phone" size="20" type="text" /><br>

<input type="submit" name="submit">

</form>
</apex:page>

thanks
Best Answer chosen by Yash Sadeghi
Gabriel ArribasGabriel Arribas
Hi Yash,

here you have your correct code. I hope it help you.

<apex:page >
<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">

    <input type="hidden" name="oid" value="00D58000000bQkZ"/>
    <input type="hidden" name="retURL" value="http://cognizant-interest.com/form"/>

<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: These fields are optional debugging elements. Please uncomment    -->
<!--  these lines if you wish to test in debug mode.                          -->
<!--  <input type="hidden" name="debug" value=1>                              -->
<!--  <input type="hidden" name="debugEmail"                                  -->
<!--  value="yashar.sadeghi@cognizant.com">                                   -->
<!--  ----------------------------------------------------------------------  -->

    <label for="first_name">First Name</label><input  id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br/>

    <label for="last_name">Last Name</label><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br/>

    <label for="email">Email</label><input  id="email" maxlength="80" name="email" size="20" type="text" /><br/>

    <label for="phone">Phone</label><input  id="phone" maxlength="40" name="phone" size="20" type="text" /><br/>

    <input type="submit" name="submit"/>

</form>
</apex:page>

All Answers

Gabriel ArribasGabriel Arribas
Hi Yash,

here you have your correct code. I hope it help you.

<apex:page >
<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">

    <input type="hidden" name="oid" value="00D58000000bQkZ"/>
    <input type="hidden" name="retURL" value="http://cognizant-interest.com/form"/>

<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: These fields are optional debugging elements. Please uncomment    -->
<!--  these lines if you wish to test in debug mode.                          -->
<!--  <input type="hidden" name="debug" value=1>                              -->
<!--  <input type="hidden" name="debugEmail"                                  -->
<!--  value="yashar.sadeghi@cognizant.com">                                   -->
<!--  ----------------------------------------------------------------------  -->

    <label for="first_name">First Name</label><input  id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br/>

    <label for="last_name">Last Name</label><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br/>

    <label for="email">Email</label><input  id="email" maxlength="80" name="email" size="20" type="text" /><br/>

    <label for="phone">Phone</label><input  id="phone" maxlength="40" name="phone" size="20" type="text" /><br/>

    <input type="submit" name="submit"/>

</form>
</apex:page>
This was selected as the best answer
Yash SadeghiYash Sadeghi
@Gabriel thank you so much, it worked :)
Gabriel ArribasGabriel Arribas
There was only one issue many times: you forgot to close some <input> and <br> tags al the end of the line with ' />'

If this solved your issue, please mark as best answer :)