I have 3 divs which is coming one by one after clicking on Next button. (Registration Process)
The fist div(id:rws-reg1) contains customer referene number and Postcode and next button.
Issue: After clicking on next button, second div(id:rws-reg2) comes but the validation "enter customer reference number" comes on next div Page.
I have the following code:
<script>
$(document).ready(function () {
$("#rws-reg1").show();
$("#rws-reg2").hide();
$("#rws-reg3").hide();
$('#btnNxtEmail').click(function () {
$("#rws-reg2").show();
$("#rws-reg1").hide();
$("#rws-reg3").hide();
})
})
</script>
<div class="registration">
<div class="limiter rws-main" id="dvMain">
<div class="container-login100 rws-login" id="rws-reg1">
<div class="wrap-login100 rws-login-wrap">
<form action="" class="login100-form validate-form-meter-read rws-meter-read validate-change-password validate-registration" method="post">
<span class="login100-form-title rws-form-title">
Account Details
</span>
<div class="wrap-input100">
<p class="rws-formp">Customer Reference:<span style="color: Red">*</span></p>
<input id="txtCustomerRef" class="input100" type="text" name="custRef" placeholder="Customer Reference" autocomplete="off">
<a href="#" data-toggle="popover" title="" data-placement="right" data-html="true" data-content="
<p>Your customer reference number is shown on your bill.</p>" data-original-title="">
<i class="fa fa-question-circle" style="font-size:20px;color:purple; margin-left:5px;"></i>
</a>
</div>
<div class="wrap-input100">
<p class="rws-formp">Postcode:<span style="color: Red">*</span></p>
<input id="txtPostcode" class="input100" type="text" name="postcode" placeholder="Postcode" autocomplete="off">
</div>
<div class="container-login100-form-btn rws-form-btn">
<button id="btnNxtEmail" class="login100-form-btn rws-sbmtbtn">
<a href="#reg2">Next</a>
</button>
</div>
</form>
</div>
</div>
<div class="container-login100 rws-login" id="rws-reg2">
....
</div>
<div class="container-login100 rws-login" id="rws-reg3">
....
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$('#btnNxtEmail').click(function () {
NxtEmail_data();
return false;
})
function NxtEmail_data() {
var CustReference = "", Postcode = ""
CustReference = $("#txtCustomerRef").val();
if (CustReference == '') {
var itemRow = "<ul id='listError'><li>" + "Please enter Customer reference number" + "</li></ul>";
FUNMessageBox(itemRow, "E", 400, 0, "", "");
return false;
}
Postcode = $("#txtPostcode").val();
if (Postcode == '') {
var itemRow = "<ul id='listError'><li>" + "Please enter postcode" + "</li></ul>";
FUNMessageBox(itemRow, "E", 400, 0, "", "");
return false;
}
if (CheckPostcode(Postcode)) {
var mst_dataConfirmRef = {
CUSTOMER_REF: CustReference,
COAPOSTCODE: Postcode
}
var DataConfirmRef = JSON.stringify(mst_dataConfirmRef);
var url = '@Url.Action("CheckAccountRegistered", "Login")';
$("#myModal").show();
$.ajax({
url: url,
data: { CheckMstData: DataConfirmRef },
dataType: 'json',
type: 'POST',
success: function (data) {
$("#myModal").hide();
if (data.Success) {
tabStrip.enable(tabStrip.tabGroup.children().eq(0), false); tabStrip.enable(tabStrip.tabGroup.children().eq(1), true); tabStrip.enable(tabStrip.tabGroup.children().eq(2), false);
tabStrip.select(1);
}
else {
var itemRow = "<ul id='listError'><li>" + data.ErrorMessage + "</li></ul>";
FUNMessageBox(itemRow, "E", 0, 0, "", "");
}
}
});
}
else {
var itemRow = "<ul id='listError'><li>" + "Incorrect postcode" + "</li></ul>";
FUNMessageBox(itemRow, "E", 0, 0, "", "");
}
}
function FUNMessageBox(itemRow, type, w, h, url, control) {
$("#divMessageContent").html(itemRow);
var wdth = w > 0 ? w : 350;
var hght = h > 0 ? h : 200;
if (type == "E") // E = Error
{
document.getElementById('divError').style.display = '';
document.getElementById('divSuccess').style.display = 'none';
document.getElementById('divQuestion').style.display = 'none';
}
if (type == "Q") // E = Question
{
document.getElementById('divQuestion').style.display = '';
document.getElementById('divError').style.display = 'none';
document.getElementById('divQuestion').style.display = 'none';
}
if (type == "S") // S = Success
{
document.getElementById('divSuccess').style.display = '';
document.getElementById('divError').style.display = 'none';
document.getElementById('divQuestion').style.display = 'none';
}
}