shell bypass 403
//JS functions for Eklavya order form
//Select or deselect (set qty=1) all the books in the current category
function selectSet(catname, list) {
//list is the select list for the current category
for(var j=0; j<list.options.length; j++)
{
if (list.options[j].selected) {
var value = list.options[j].value;
}
}
if(value != 0){
for(var i=0; i<catname.length; i++) {
//Set the quantity value to selected value
document.orderForm[catname[i]].value = value ;
//Explicitly invoke the onchange event for quantity field
document.orderForm[catname[i]].onchange();
}
}
else {
for(var i=0; i<catname.length; i++) {
document.orderForm[catname[i]].value = '';
document.orderForm[catname[i]].onchange();
}
}
}
//String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };
function trim(sInString) {
sInString = sInString.replace( /^\s+/g, "" );// strip leading
return sInString.replace( /\s+$/g, "" );// strip trailing
}
//Calculate the amount for the quantity entered. Also verify qtty value
function calcAmt(amtField, nPrice, qtyField, numBooks){
//Remove preceding and trailing blanks if any
qtyField.value = trim(qtyField.value);
if ((qtyField.value == 0) || (qtyField.value == "")){
qtyField.value = "";
amtField.value = "";
updateTot(numBooks);
return true;
}
//Validate the quantity first
if (isNaN(qtyField.value)) {
alert("Quantity must be a number!");
setTimeout(function(){qtyField.focus()}, 10); // qtyField.focus()
return false;
}
nAmt = nPrice * qtyField.value;
amtField.value = nAmt;
updateTot(numBooks);
}
//Update the total amount
function updateTot(numBooks){
totAmt = 0
for (i=0; i<numBooks; i++) {
totAmt = totAmt + Number(document.orderForm["amt"+i].value)
}
document.orderForm.total.value = Math.ceil(totAmt);
}
// This will disable enter key in form apply it using keypressed event
function disableEnterKey(e)
{
var key;
if(window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox
if(key == 13)
{
alert("Please use Tab key to move to the next field.\n Use mouse click for the Submit button.");
}
return (key != 13);
}
//Verify that the form being submitted is not blank
function verifyNoBlankForm(passForm, numBooks) {
//Check if the form is blank
isBlankForm = true
for (i=0; i<numBooks; i++) {
qty = trim(document.orderForm.elements['qty['+i+']'].value)
if (qty != "" && qty != "0") {
isBlankForm = false
break
}
}//end-for
if (isBlankForm) {
alert("You cannot submit a blank form!")
return false
}
//Check whether any quantity is still non-numeric
for (i=0; i<numBooks; i++) {
qty = trim(document.orderForm.elements['qty['+i+']'].value)
if (isNaN(qty)) {
alert('Quantity must be a number!!')
document.orderForm.elements['qty['+i+']'].focus()
return false
}
}//end-for
}
//Validate contact details
function validateContact(passForm) {
//Check for mandatory fields
if (!validateMandatory(passForm.CustName, "First Name")) return false
if (!validateMandatory(passForm.CustLastName, "Last Name")) return false
if (!validateMandatory(passForm.CustAddr, "Address")) return false
if (!validateMandatory(passForm.CustDist, "District/City")) return false
if (!validateMandatory(passForm.CustState, "State")) return false
if (!validateMandatory(passForm.CustPin, "Pin")) return false
if (!validateMandatory(passForm.CustEmail, "Email")) return false
if (!validateMandatory(passForm.CustSTD, "STD number")) return false
if (!validateMandatory(passForm.CustPhone, "Phone number")) return false
//Verify that pin is numeric
if (!validateNumeric(passForm.CustPin, "Pin code")) return false
//Verify that pin is a 6 digit number
if (passForm.CustPin.value.length != 6) {
alert("Pin code must be 6 digits long")
passForm.CustPin.focus()
return false
}
//Verify that email address is valid
if (!validateEmail(passForm.CustEmail.value)) {
alert("Invalid Email address format!")
passForm.CustEmail.focus()
return false
}
//Verify that STD & phone are numeric
if (!validateNumeric(passForm.CustSTD, "STD code")) return false
if (!validateNumeric(passForm.CustPhone, "Phone number")) return false
//Verify that mobile is numeric (implicit that this field is not blank)
if (!validateNumeric(passForm.CustMobile, "Mobile number")) return false
if(document.getElementById('CopyTheContent').value == 0)
{
/*Shipping details*/
//Check for mandatory fields
if (!validateMandatory(passForm.OrderShiptoName, "Shipping Details: First Name")) return false
if (!validateMandatory(passForm.OrderShiptoSurname, "Shipping Details: Last Name")) return false
if (!validateMandatory(passForm.OrderShiptoAddr1, "Shipping Details: Address")) return false
if (!validateMandatory(passForm.OrderShiptoCity, "Shipping Details: District/City")) return false
if (!validateMandatory(passForm.OrderShiptoState, "Shipping Details: State")) return false
if (!validateMandatory(passForm.OrderShiptoPincode, "Shipping Details: Pin")) return false
if (!validateMandatory(passForm.OrderShiptoEmail, "Shipping Details: Email")) return false
if (!validateMandatory(passForm.OrderShiptoSTD, "Shipping Details: STD number")) return false
if (!validateMandatory(passForm.OrderShiptoPhone, "Shipping Details: Phone number")) return false
//Verify that pin is numeric
if (!validateNumeric(passForm.OrderShiptoPincode, "Shipping Details: Pin code")) return false
//Verify that pin is a 6 digit number
if (passForm.OrderShiptoPincode.value.length != 6) {
alert("Shipping Details: Pin code must be 6 digits long")
passForm.OrderShiptoPincode.focus()
return false
}
//Verify that email address is valid
if (!validateEmail(passForm.OrderShiptoEmail.value)) {
alert("Shipping Details: Invalid Email address format!")
passForm.OrderShiptoEmail.focus()
return false
}
//Verify that STD & phone are numeric
if (!validateNumeric(passForm.OrderShiptoSTD, "Shipping Details: STD code")) return false
if (!validateNumeric(passForm.OrderShiptoPhone, "Shipping Details: Phone number")) return false
//Verify that mobile is numeric (implicit that this field is not blank)
if (!validateNumeric(passForm.OrderShiptoMobile, "Shipping Details: Mobile number")) return false
}
}
//Validate mandatory field
function validateMandatory(passField, fieldName) {
passField.value = trim(passField.value)
if (passField.value == "") {
alert(fieldName + " must be entered!")
passField.focus()
return false
}
return true
}
//Validate numeric field
function validateNumeric(passField, fieldName) {
passField.value = trim(passField.value)
if (isNaN(passField.value)) {
alert(fieldName + " must be a number")
passField.focus()
return false
}
return true
}
//Validate email id format
function validateEmail(email) {
invalidChars = " /:,;"
for (i=0; i<invalidChars.length; i++) {
badChar = invalidChars.charAt(i)
if (email.indexOf(badChar,0) > -1) {
return false
}
}
atPos = email.indexOf("@", 1)
if (atPos == -1) {
return false
}
if (email.indexOf("@", atPos+1) > -1) {
return false
}
periodPos = email.indexOf(".", atPos)
if (periodPos == -1) {
return false
}
if (periodPos+3 > email.length) {
return false
}
return true
}
function CopyShippingDtls()
{
document.getElementById("OrderShiptoName").value = document.getElementById("CustName").value;
document.getElementById("OrderShiptoSurname").value = document.getElementById("CustLastName").value;
document.getElementById("OrderShiptoCompanyName").value = document.getElementById("CustCompanyName").value;
document.getElementById("OrderShiptoAddr1").value = document.getElementById("CustAddr").value;
document.getElementById("OrderShiptoAddr2").value = document.getElementById("CustStreet").value;
document.getElementById("OrderShiptoAddr3").value = document.getElementById("CustTaluka").value;
document.getElementById("OrderShiptoCity").value = document.getElementById("CustDist").value;
document.getElementById("OrderShiptoState").value = document.getElementById("CustState").value;
document.getElementById("OrderShiptoPincode").value = document.getElementById("CustPin").value;
document.getElementById("OrderShiptoEmail").value = document.getElementById("CustEmail").value;
document.getElementById("OrderShiptoSTD").value = document.getElementById("CustSTD").value;
document.getElementById("OrderShiptoPhone").value = document.getElementById("CustPhone").value;
document.getElementById("OrderShiptoMobile").value = document.getElementById("CustMobile").value;
}
function ResetShippingAddressFields()
{
if(document.getElementById("NotSameAsAbove").checked)
{
document.getElementById("shipping_address").style.display = 'block';
document.getElementById("CopyTheContent").value = 0;
document.getElementById("OrderShiptoName").value = '';
document.getElementById("OrderShiptoSurname").value = '';
document.getElementById("OrderShiptoCompanyName").value = '';
document.getElementById("OrderShiptoAddr1").value = '';
document.getElementById("OrderShiptoAddr2").value = '';
document.getElementById("OrderShiptoAddr3").value = '';
document.getElementById("OrderShiptoCity").value = '';
document.getElementById("OrderShiptoState").value = '';
document.getElementById("OrderShiptoPincode").value = '';
document.getElementById("OrderShiptoEmail").value = '';
document.getElementById("OrderShiptoSTD").value = '';
document.getElementById("OrderShiptoPhone").value = '';
document.getElementById("OrderShiptoMobile").value = '';
}else
{
document.getElementById("shipping_address").style.display = 'none';
document.getElementById("CopyTheContent").value = 1;
}
}