Online HTML Form

An online html form designed for Rent a Satellite Phone Zoro.

Jira code: RSPZ-206

<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/momentjs/2.14.1/moment.min.js"></script>

    <link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    <style>
        input[type=text],
        input[type=number],
        input[type=email],
        textarea {
            width: 600px !important;
            padding: 12px;
            border: none !important;
            border-radius: 4px;
            box-sizing: border-box;
            margin-top: 6px;
            margin-bottom: 16px;
            font-size: 15px !important;
            /* color: #757575 !important; */
            color: #222;
            background: #ebebeb;
            outline: none !important;

        }

        select {
            height: 45px;
            width: 600px !important;
            padding: 12px;
            border: none;
            border-radius: 4px;
            box-sizing: border-box;
            margin-top: 6px;
            margin-bottom: 16px;
            font-size: 15px !important;
            color: #757575 !important;
            background: #ebebeb;
            outline: none !important;
        }

        input[type=text]::-webkit-input-placeholder {
            /* Chrome/Opera/Safari */
            color: #757575 !important;
        }

        input[type=text]:focus::-webkit-input-placeholder {
            /* Chrome/Opera/Safari */
            color: #222 !important;
        }

        input[type=text]:focus::-moz-placeholder {
            /*firefox*/
            color: #222 !important;
        }

        input[type=text]:focus:-moz-placeholder {
            /*firefox*/
            color: #222 !important;
        }

        input[type=text]:-ms-input-placeholder {
            /* IE 10+ */
            color: #222 !important;
        }

        textarea:focus::-webkit-input-placeholder {
            /* Chrome/Opera/Safari */
            color: #222 !important;
        }

        textarea:focus:focus:-moz-placeholder {
            color: #222 !important;
        }

        textarea:focus::-moz-placeholder {
            color: #222 !important;
        }

        textarea:focus:-ms-input-placeholder {
            color: #222 !important;
        }

        input[type=submit] {
            color: #0071BC;
            border: 2px solid #0071BC;
            font-size: 18px;
            line-height: 1.1;
            padding: 11px 28px;
            text-decoration: none;
            text-align: center;
            outline: none;
            font-weight: 600;
            margin-left: 480px;
            background: white;

        }

        input[type=submit]:hover {
            background: #0071BC;
            border-color: #0071BC;
            color: #fff;
        }


        body {
            padding: 40px !important;
        }

        @media(min-width:768px) {
            body {
                text-align: center;
            }

            #custrecord_satphone_date_out,
            #custrecord_satphone_date_in {
                margin-left: 22px;
            }

        }

        @media(max-width:767px) {
            input[type=submit] {
                float: right;
margin-bottom:30px;
            }

            input[type=text],
            input[type=number],
            input[type=email],
            textarea,
            select {
                width: 100% !important;
            }

            .last-content {
                margin-top: 58px !important;
            }

        }

        .textStyle {
            color: #0f3a6b;
        }

        #name,
        #custrecord_last_name,
        #custrecord_first_name,
        #custrecord2,
        #custrecord_cus_reference_info,
        #custrecord_satphone_date_out,
        #custrecord_satphone_date_in,
        #custrecord3,
        #custrecord5,
        #custrecord_number_of_phones {
            border: none;
            height: 45px;
            font-size: 15px;
        }

        .subheading {
            margin-bottom: 15px;
            font-size: 15px;
        }

        .title {
            font-size: 24px;
            margin-bottom: 28px;
            font-weight: 700;
        }

        .field_widget_pos {
            left: 3px !important;
        }

        .smalltextul {
            color: black;
        }

        .lastline {
            font-size: 15px;
            line-height: 25px;
        }

        .last-content {
            margin-top: 20px;
        }

        /* #custrecord_number_of_phones::-webkit-inner-spin-button{
display:none;
} */
        input[type="number"]::-webkit-outer-spin-button,
        input[type="number"]::-webkit-inner-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }

        input[type="number"] {
            -moz-appearance: textfield;
        }

        /* Change the white to any color */


        input:-webkit-autofill,
        textarea:-webkit-autofill,
        select:-webkit-autofill {
            transition-delay: 3600s;
        }

        @media(min-width:768px) {
            .main-heading {
                text-align: center;
            }

            .last-content {
                text-align: center;
                width: 600px;
                margin: auto;
            }

            .inside-main-heading {
                text-align: left;
                display: inline-block;
                margin-right: 368px;
            }

            .inside-last-content {
                text-align: left;
                display: inline-block;

            }
        }

        .zoom {
            padding: 20px;

            transition: transform .2s;

            margin: 0 auto;
        }

        .zoom:hover {
            -ms-transform: scale(1.2);
            /* IE 9 */
            -webkit-transform: scale(1.2);
            /* Safari 3-8 */
            transform: scale(1.2);
        }

        #ui-datepicker-div {

            width: auto;
        }

        .ui-widget-content {
            background: #eeeeee !important;
        }

        .ui-datepicker-header {
            background: #484848;
            border: none;
        }

        .ui-datepicker table {
            BACKGROUND: #EEEEEE;
        }

        .ui-state-default {
            color: #606060 !important;
        }

        .ui-state-highlight {
            border: none !important;
            background: white !important;
        }

        .ui-state-active {
            border: 1px solid black !important;

        }

        .ui-datepicker-prev,
        .ui-datepicker-next {
            background: none !important;
            border: none !important;
        }

        @media(min-width:768px) {
            .flexclass {

                display: inline-flex;
                width: 600px;
            }

            #datepicker1 {
                width: 295px !important;
                margin-right: 5px;
            }

            #datepicker2 {
                width: 295px !important;
                margin-left: 5px;
            }

            #custrecord_first_name {
                width: 295px !important;
                margin-right: 5px;
            }

            #custrecord_last_name {
                width: 295px !important;
                margin-left: 5px;
            }
        }


        @media(min-width:500px) and (max-width:767px) {
            .flexclass {

                display: inline-flex;
                width: 99% !important;
            }

            .dateres {
                width: 100% !important;
            }

            #datepicker1 {

                margin-right: 5px;
            }

            #datepicker2 {

                margin-left: 5px;
            }

            #custrecord_first_name {

                margin-right: 5px;
            }

            #custrecord_last_name {

                margin-left: 5px;
            }

        }

        input[type=checkbox] {
            visibility: hidden;
        }

        .checkboxFive label {
            cursor: pointer;
            position: absolute;
            width: 20px;
            height: 20px;
            top: 0;
            left: 0;
            background: #eee;
            border: 1px solid #ddd;
        }

        .checkboxFive label:after {
            opacity: 0;
            content: '';
            position: absolute;
            width: 9px;
            height: 5px;
            background: transparent;
            top: 6px;
            left: 7px;
            border: 3px solid #333;
            border-top: none;
            border-right: none;

            transform: rotate(-45deg);
        }

        .checkboxFive label:hover::after {
            opacity: 0;
        }

        /**
 * Create the checkbox state for the tick
 */
        .checkboxFive input[type=checkbox]:checked+label:after {
            opacity: 1;
        }

        .checkboxFive {

            margin: 20px 100px;
            position: relative;
            text-align: left;
            margin: auto;
            width: 600px;
            display: flex;
            margin-bottom: 3px;
            margin-top: -10px;
        }

        @media(max-width:767px) {
            .checkboxFive {
                width: 100%;
            }
        }

        @media(max-width:395px) {
            .checkboxFive {
                margin-top: 0px;
            }

            .checkboxFive label {
                top: -3px;
            }
        }

        textarea:disabled {
            background: #dddddd;
        }
    </style>
</head>

<body>
    <div class="main-heading">
        <div class="inside-main-heading">
            <h2 class="title">Rental Request form</h2>

        </div>
    </div>

    <NLFORM>


        <p>
            <nlcustrecord2>
        </p>
        <div class="flexclass">
            <p class="dateres">
                <nlcustrecord_first_name>
            </p>
            <p class="dateres">
                <nlcustrecord_last_name>
            </p>
        </div>
        <p>
            <nlcustrecord_cus_reference_info>
        </p>
        <p>
            <nlcustrecord5>
        </p>
        <p>
            <nlcustrecord3>
        </p>
        <p hidden>
            <nlcustrecord_satphone_date_out>
        </p>
        <p hidden>
            <nlcustrecord_satphone_date_in>
        </p>
        <div class="flexclass">
            <p class="dateres"><input type="text" id="datepicker1"></p>
            <p class="dateres"><input type="text" id="datepicker2"></p>
        </div>
        <p>
            <nlcustrecord_spr_delivery_required>
        </p>

        <p>
            <nlcustrecord_shipping_address>
        </p>
        <!-- <p class="checkline">
        <label for="vehicle1"> Billing Address same as Shipping Address<input type="checkbox" id="checkbox1" name="vehicle1"><span class="geekmark"></span></label></p> -->
        <div class="checkboxFive">
            <p><input type="checkbox" value="1" id="checkboxFiveInput" name="" />
                <label for="checkboxFiveInput"></label><span style="padding-left:10px;font-size:15px;">Billing Address
                    same as Shipping Address</span></p>
        </div>
        <p>
            <nlcustrecord_billing_address>
        </p>

        <p>
            <nlcustrecord_type_of_phone>
        </p>
        <p>
            <nlcustrecord_number_of_phones>
        </p>
        <p>
            <nlcustrecord_comments>
        </p>

        <p>
            <nlcustrecordcontact_email>
        </p>
        <p>
            <nlcustrecord_email>
        </p>
        <p>
            <nlcustrecord7>
        </p>
        



        <input id="subtn" class="zoom" type="submit" value="Submit">
    </NLFORM>
    <script>
        $(function () {
            $('#custrecord2').attr("placeholder", "Company Name");
            $('#custrecord_first_name').attr("placeholder", "*First Name");
            $('#custrecord_last_name').attr("placeholder", "*Last Name");
            $('#custrecord_cus_reference_info').attr("placeholder", "Customer Reference");
            $('#custrecord5').attr("placeholder", "*Email");
            $('#custrecord3').attr("placeholder", "*Phone Number");
            $('#custrecord_satphone_date_out').attr("placeholder", "*Rental Start Date");
            $('#custrecord_satphone_date_in').attr("placeholder", "*Rental End Date");
            $('#datepicker1').attr("placeholder", "*Rental Start Date");
            var strvalue = $("#datepicker1").val();

            $('#datepicker2').attr("placeholder", "*Rental End Date");
            var strvalue2 = $("#datepicker2").val();
            $("#custrecord_spr_delivery_required").append(
                "<option value='' hidden selected>Delivery Required?</option>");
            $('#custrecord_shipping_address').attr("placeholder", "Shipping Address");
            $('#custrecord_billing_address').attr("placeholder", "*Billing Address");

            $("#custrecord_type_of_phone").append("<option value='' selected hidden>Type Of Phone</option>");
            $('#custrecord_number_of_phones').attr("placeholder", "Number Of Phones");


            $('#custrecord_number_of_phones').attr("onkeypress", "return event.charCode >= 48");
            $('#custrecord_comments').attr("placeholder", "Other Comments");
            $("#checkboxFiveInput").prop('checked', true);
            $("#custrecord_billing_address").hide();
            $('#custrecord_number_of_phones').val('');
           


            $(window).on('load', function() {
    console.log('All assets are loaded');
  
    $('#custrecord_number_of_phones').val('');
    

})
            $(document).ready(function () {

            
                $('input[type="checkbox"]').click(function () {
                    if ($(this).prop("checked") == true) {
                        console.log("Checkbox is checked.");
                        $("#custrecord_billing_address").hide();
                        var shippingAddress = shippingAddrssCalc();
                        $('#custrecord_billing_address').val(shippingAddress);

                    } else if ($(this).prop("checked") == false) {
                        console.log("Checkbox is unchecked.");
                        $('#custrecord_billing_address').val('');
                        $("#custrecord_billing_address").show();

                    }
                });
            });

            $("#custrecord_shipping_address").change(function () {
                if ($("#checkboxFiveInput").prop("checked") == true) {
                    console.log("Checkbox is checked.");
                    var shippingAddress = shippingAddrssCalc();
                    $('#custrecord_billing_address').val(shippingAddress);
                }

            });

            function shippingAddrssCalc() {

                var findshippingAddress = $('#custrecord_shipping_address').val();
                console.log('findshippingAddress', findshippingAddress);
                return findshippingAddress;

            }


            $(function () {
                $('#datepicker1').datepicker({
                    minDate: 0,
                    beforeShowDay: $.datepicker.noWeekends
                });

            });
            $(function () {
                $('#datepicker2').datepicker({
                    minDate: 0,
                    beforeShowDay: $.datepicker.noWeekends
                });
            });

            $("#datepicker1").change(function () {
                var strvalue = $("#datepicker1").val();
                console.log('strvalue', strvalue);
                var date = formatDate(strvalue);
                console.log('date', date);


                $('#custrecord_satphone_date_out').val(date);
            });
            $("#datepicker2").change(function () {
                var strvalue2 = $("#datepicker2").val();
                console.log('strvalue2', strvalue2);
                var date2 = formatDate(strvalue2);
                console.log('date2', date2);


                $('#custrecord_satphone_date_in').val(date2);
            });

        })
        $("#datepicker1").click(function () {
            var width = window.innerWidth;
            if (width <= "768") {

                $('html,body').animate({
                    scrollTop: $("#custrecord3").offset().top
                });
            }
        });

        $("#datepicker2").click(function () {
            var width = window.innerWidth;
            if (width <= "768") {

                $('html,body').animate({
                    scrollTop: $("#custrecord3").offset().top
                });
            }
        });

        function formatDate(strvalue) {
            var d = new Date(strvalue),
                month = '' + (d.getMonth() + 1),
                day = '' + d.getDate(),
                year = d.getFullYear();

            return [day, month, year].join('/');
        }

      
           
        
     

    </script>

</body>

</html>

Client script to set fields in custom record.

/**
 * Module Description
 * 
 * Version    Date            Author           Remarks
 * 1.00       20 Aug 2013     Steven Wall
 *
 */
 jQuery(function(){
 
    //texarea width
    jQuery('.textarea').css('width','199');
    
    // date picker 
    jQuery('.field_widget_pos').attr('style', 'left:3px !important');

});
/* Added in script */
/**
 * The recordType (internal id) corresponds to the "Applied To" record in your
 * script deployment.
 * 
 * @appliedtorecord recordType
 * 
 * @param {String}
 *            type Sublist internal id
 * @param {String}
 *            name Field internal id
 * @param {Number}
 *            linenum Optional line item number, starts from 1
 * @returns {Void}
 */
function clientFieldChanged(type, name) {
	if (name == 'custrecord5') {
		
		try {
          var cusEmail = nlapiGetFieldValue('custrecord5');
          console.log('cusEmail', cusEmail);
		nlapiSetFieldValue('custrecord_email', cusEmail);
			nlapiSetFieldValue('custrecordcontact_email', cusEmail);
			
		} catch (e) {
			console.log(e.message);
			nlapiLogExecution('DEBUG', 'setcontact email', e.message);
		}
	}
	if (name == 'custrecord_satphone_date_in') {
		try {
			var renStartDate = nlapiGetFieldValue('custrecord_satphone_date_out');
			var renEndDate = nlapiGetFieldValue('custrecord_satphone_date_in');
			var date1 = nlapiStringToDate(renStartDate, 'datetimetz');
			var date2 = nlapiStringToDate(renEndDate, 'datetimetz');
			var date_diff_indays = dateDiffIndays(date1, date2);
			nlapiSetFieldValue('custrecord4', date_diff_indays);
			
		} catch (e) {
			console.log(e.message);
			nlapiLogExecution('DEBUG', 'setcontact email', e.message);
		}

	}

}
function saveRecord(type, name) {
	try{
		
		var numOfPhone = nlapiGetFieldValue('custrecord_number_of_phones');
		console.log(numOfPhone);
		if(numOfPhone == ""){
			nlapiSetFieldValue('custrecord_number_of_phones', 1);
		}
    var cusEmailsave = nlapiGetFieldValue('custrecord5');
          console.log('cusEmailsave', cusEmailsave);
		nlapiSetFieldValue('custrecord_email', cusEmailsave);
			nlapiSetFieldValue('custrecordcontact_email', cusEmailsave);

	}
	catch (e) {
		console.log(e.message);
		nlapiLogExecution('DEBUG', 'error-saveRecord', e.message);
	}

}

// To calculate the total days out
function dateDiffIndays(date1, date2) {
	// var date1 = new Date(date1);
	// var date2 = new Date(date2);
	var timeDiff = Math.abs(date2.getTime() - date1.getTime());
	var diffDays = (Math.ceil(timeDiff / (1000 * 3600 * 24))) + 1;
	return diffDays;
}
/* End of added in script */

Leave a comment

Your email address will not be published. Required fields are marked *