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
Indoberto LermaIndoberto Lerma 

2 functions on submit

Hi,
i am creating a visualforce page and on this page i need to concatenate fields and also make them required.
So far i was able to do both things, but i havent been able to acomplish both at the same time. i am using myfunction concatenate and validateform. how can i asociate both on the onsubmit button?

this is the code i have for both functions.



<form action="https://cs19.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8" method="POST" onsubmit="myFunction()" >

 <script>
function validateForm()
{

var a=document.forms["webtocase"]["name"].value;
if (a==null || a=="")
{
alert("Nombre de usuario no puede dejarse en blanco"); return false; }

</script>


<script>
function myFunction()
{
var str5 = "New Hire"; var str3 = "Nombre: " + document.getElementById("name").value + '\r\n';
var str1 = document.getElementById("email").value + '\r\n';
var str2 = document.getElementById("phone").value + '\r\n';
var str4 = document.getElementById("subject").value;
var res = str5.concat(str3, str1, str2, str4);
document.getElementById("description").innerHTML=res;
}
</script>


Description:<textarea id="description" name="description" rows="15" type="text" wrap="soft" ></textarea><br/>
<input type="hidden" id="external" name="external" value="1" /><br/>

<input type="submit" name="submit" onsubmit="myFunction()"/>

</form>




 
AshlekhAshlekh
Hi,

You can call both method in single method and check.

-Thanks
Ashlekh Gera
BM 5BM 5
Can you try the below code

form action="https://cs19.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8" method="POST" onsubmit="myFunction()" >

<script>
function myFunction()
{
var str5 = "New Hire"; var str3 = "Nombre: " + document.getElementById("name").value + '\r\n';
var str1 = document.getElementById("email").value + '\r\n';
var str2 = document.getElementById("phone").value + '\r\n';
var str4 = document.getElementById("subject").value;
var res = str5.concat(str3, str1, str2, str4);
document.getElementById("description").innerHTML=res;

var a=document.forms["webtocase"]["name"].value;
if (a==null || a=="")
{
alert("Nombre de usuario no puede dejarse en blanco"); return false; }

}
</script>


Description:<textarea id="description" name="description" rows="15" type="text" wrap="soft" ></textarea><br/>
<input type="hidden" id="external" name="external" value="1" /><br/>

<input type="submit" name="submit" onsubmit="myFunction()"/>

</form>