这是我关于堆栈溢出的第一个问题。如果有前辈来帮助我,我会很高兴的。我的注册表单(提交/保存时)显示红色或绿色条,并显示您的表单是否成功提交。但它只显示 1 秒,这还不够,也没有引起注意,因为客户认为她。他的表格没有提交。有人可以指导我该怎么做才能纠正这个问题吗?这是我正在使用的js代码:
<script type="text/javascript">
function addNewFileUpload()
{
var total_file_upload = jQuery('#total_file_upload').val();
total_file_upload = parseInt(total_file_upload) + 1;
var content = '<br><div class="control"><input title="<?php echo __('Files'); ?>" type="file" name="varification_proof_' + total_file_upload + '" id="varification_proof_' + total_file_upload + '" class="input-text required-entry" data-validate="{required:true}" aria-required="true" /></div>';
jQuery('#verification_proof_container').append(content);
jQuery('#total_file_upload').val(total_file_upload);
}
function validate(id, field, limit)
{
console.log('#' + id);
value = jQuery('#' + id).val();
console.log(value.length + '=======' + limit);
if (value.length == limit)
{
jQuery('#' + id + 'promptmsg').html(field + ' must contain ' + limit + ' characters');
jQuery('div #' + id + 'promptmsg').css('display', 'block');
}
else
{
jQuery('div #' + id + 'promptmsg').css('display', 'none');
}
}
function validatenumber(id, field, limit)
{
console.log('#' + id);
var value = jQuery('#' + id).val();
if (value.length >= limit)
{
console.log(value.length + '=======' + limit);
jQuery('#contactnumpromptmsg').html('Invalid contact number');
jQuery('#contactnumpromptmsg').css('display', 'block');
} else
{
jQuery('#contactnumpromptmsg').css('display', 'none');
}
}
function validateNTNnumber(id, field, limit)
{
console.log('#' + id);
var value = jQuery('#' + id).val();
if (value.length >= limit)
{
console.log(value.length + '=======' + limit);
jQuery('#NTNnumpromptmsg').html('Invalid NTN number');
jQuery('#NTNnumpromptmsg').css('display', 'block');
} else
{
jQuery('#contactnumpromptmsg').css('display', 'none');
}
}
function validatepassword()
{
var password = document.getElementById("password").value;
var confirmPassword = document.getElementById("confirmation").value;
if (password != confirmPassword)
{
jQuery('#passwordmsg').html('Passwords do not match.');
jQuery('#passwordmsg').css('display', 'block');
}
else
{
jQuery('#passwordmsg').css('display', 'none');
}
}
var currentTab = 0; // Current tab is set to be the first tab (0)
showTab(currentTab); // Display the crurrent tab
function showTab(n)
{
// This function will display the specified tab of the form...
var x = document.getElementsByClassName("tab");
x[n].style.display = "block";
//... and fix the Previous/Next buttons:
if (n == 0)
{
document.getElementById("prevBtn").style.display = "none";
} else
{
document.getElementById("prevBtn").style.display = "inline";
}
if (n == (x.length - 1))
{
document.getElementById("save").style.display = "inline";
document.getElementById("nextBtn").style.display = "none";
} else
{
document.getElementById("save").style.display = "none";
}
//... and run a function that will display the correct step
indicator:
fixStepIndicator(n)
}
function nextPrev(n)
{
// This function will figure out which tab to display
var x = document.getElementsByClassName("tab");
// Exit the function if any field in the current tab is invalid:
if (n == 1 && !validateForm()) return false;
// Hide the current tab:
x[currentTab].style.display = "none";
// Increase or decrease the current tab by 1:
currentTab = currentTab + n;
// if you have reached the end of the form...
if (currentTab >= x.length)
{
// ... the form gets submitted:
document.getElementById("regForm").submit();
return false;
}
// Otherwise, display the correct tab:
showTab(currentTab);
}
function validateForm()
{
// This function deals with validation of the form fields
var x, y, i, valid = true;
x = document.getElementsByClassName("tab");
y = x[currentTab].getElementsByTagName("input");
// A loop that checks every input field in the current tab:
for (i = 0; i < y.length; i++)
{
// If a field is empty...
if (y[i].value == "")
{
// add an "invalid" class to the field:
y[i].className += " invalid";
// and set the current valid status to false
valid = false;
}
}
// If the valid status is true, mark the step as finished and
valid:
if (valid)
{
document.getElementsByClassName("step")[currentTab].className += "
finish";
}
return valid; // return the valid status
}
function fixStepIndicator(n)
{
// This function removes the "active" class of all steps...
var i, x = document.getElementsByClassName("step");
for (i = 0; i < x.length; i++)
{
x[i].className = x[i].className.replace(" active", "");
}
//... and adds the "active" class on the current step:
x[n].className += " active";
}
</script>
</div>
<?php $session->destroy();?>