Required Fields Alert Box

This code will allow you to use Javascript to make fields required, rather than the source key settings. You may want to use this rather than the built-in required fields settings as an alternate way of requiring those fields to be filled out. The main difference between this and our built-in required fields handling is that this will ensure fields are filled out before the customer leaves the page - some web browsers will erase all data if the customer leaves the page.

Log into your Newtek Gateway merchant gateway. Go to "Settings", then "Source Keys". Select the source key you are using and click "Edit". Click "Edit Customization to Epay Form".

Insert this code into the document head:

<script>
function verify() 
{
var themessage = "Please complete the following fields: ";
if (document.epayform.UMname.value=="") {
themessage = themessage + " - Cardholder Name";
}
//alert if fields are empty and cancel form submit
if (themessage == "Please complete the following fields: ") {
document.epayform.submit();
return true;
}
else {
alert(themessage);
return false;
 }
}
</script>

You can make as many fields required as you want. To make a field required, repeat this section of code:

if (document.epayform.UMfield.value=="") { themessage = themessage + " - Name Of Field"; }

Scroll down to the bottom of the form and look for this line:

<input type="submit" name="submitbutton" value="Process Payment &gt;&gt;">

Change it to read:

<input type="submit" name="submitbutton" value="Process Payment &gt;&gt;" onclick="return verify();">

If the required field you want to add is also under the hidden fields section at the top of the form, remove the hidden field's line in accordance to the field. If the field you chose isn't in the hidden fields section you do not have to do this step. Example : UMinvoice as a required field. UMinvoice is in the hidden fields section.

Delete from Hidden Fields Section :

<input type="hidden" name="UMinvoice" value="[UMinvoice]">

Required Fields Inline Instructions

This code uses Javascript to make fields required. It is similar to [[:merchant:epaymentform:reqfields|Required Field prompts]] except that it indicates which fields are required when the customer lands on the payment form. Another difference is that after it validates the form, it provides inline instructions for the customer as opposed to instructions in an alert box. It has the same advantage [[:merchant:epaymentform:reqfields|Required Field prompts]] has as opposed to use of source key settings because it keeps the customer on the same page if the required fields are blank. Some web browsers will erase all form data if the customer uses the back page to return to the form.

Log into your Newtek Gateway merchant gateway. Go to "Settings", then "Source Keys". Select the source key you are using and click "Edit". Click "Edit Customization to Epay Form".

Insert this code into the document head:

<script>
function verify() 
{
var themessage = "Please complete the following fields: ";
themessage = themessage + "<ul>";
if (document.epayform.UMname.value=="") {
themessage = themessage + "<li>Cardholder Name</li>";
}
if (document.epayform.UMcard.value=="") {
themessage = themessage + "<li> Card Number</li>";
}
if (document.epayform.UMexpir.value=="") {
themessage = themessage + "<li> Card Expiration Date</li>";
}
themessage = themessage + "</ul>";
//alert if fields are empty and cancel form submit
if (themessage == "Please complete the following fields: <ul></ul>") {
document.epayform.submit();
return true;
}
else {
document.getElementById('required').innerHTML = "<font color=\"#FF0000\">" + themessage + "</font>";
window.scrollTo(0,0);
return false;
 }
}
</script>

You can make as many fields required as you want. To make a field required, repeat this section of code. Please note, requiring fields that are not on your payment form will break the entire field verification, causing no field requirements:

if (document.epayform.UMfield.value=="") { themessage = themessage + "<li> Name of Field</li>"; }

Create inline instructions. First find:

<tr>
    <td bgcolor="#F0F0F0" width="692" colspan="2">&nbsp;</td>
</tr>

Replace it with

<tr>
   <td bgcolor="#F0F0F0" width="692" colspan="2" align="center">

      <table>
     <tr>
    <td>
    <div id="required"><font size="2" face="Verdana" color="#ff0000">*</font><font size="2" face="Verdana"> indicates a required field.</font></div>&nbsp;
    </td>
    </tr>
    </table>

   </td>
</tr>

Create red *'s. Find:

<td bgcolor="#F0F0F0" width="450"> <input type="text" name="UMname" size="25" value="[UMname]"></td>

Replace it with:

<td bgcolor="#F0F0F0" width="450">
<input type="text" name="UMname" size="25" value="[UMname]"> <font face="Verdana" size="2"color="#ff0000">*</font></td>

Find:

<tr>
    <td bgcolor="#F0F0F0" width="234" align="right"><font face="Verdana" size="2">Card Number:</font></td>
    <td bgcolor="#F0F0F0" width="450">
    <input type="text" name="UMcard" size="17"></td>
</tr>
<tr>
    <td bgcolor="#F0F0F0" width="234" align="right"><font face="Verdana" size="2">Card Expiration Date: </font></td>
    <td bgcolor="#F0F0F0" width="450">
    <input type="text" name="UMexpir" size="4"> MMYY</td>
</tr>

Replace it with:

<tr>
    <td bgcolor="#F0F0F0" width="234" align="right"><font face="Verdana" size="2">Card Number:</font></td>
    <td bgcolor="#F0F0F0" width="450">
    <input type="text" name="UMcard" size="17"> <font face="Verdana" size="2"color="#ff0000">*</font></td>
</tr>
<tr>
    <td bgcolor="#F0F0F0" width="234" align="right"><font face="Verdana" size="2">Card Expiration Date: </font></td>
    <td bgcolor="#F0F0F0" width="450">
    <input type="text" name="UMexpir" size="4"> MMYY <font face="Verdana" size="2"color="#ff0000">*</font></td>
</tr> 

For every additional field, find

<input type="text" name="UMfield" size="x" value="[UMfield]">

Replace it with

<input type="text" name="UMfield" size="x" value="[UMfield]"> <font face="Verdana" size="2"color="#ff0000">*</font>

Modify submit button. Find:

<input type="submit" name="submitbutton" value="Process Payment &gt;&gt;">

Replace it with

<input type="submit" name="submitbutton" value="Process Payment &gt;&gt;" onclick="return verify();">

If the required field you want to add is also under the hidden fields section at the top of the form, remove the hidden field's line in accordance to the field. If the field you chose isn't in the hidden fields section you do not have to do this step.

Example : UMinvoice as a required field. UMinvoice is in the hidden fields section.

Delete from Hidden Fields Section :

<input type="hidden" name="UMinvoice" value="[UMinvoice]">