我已经使用SweetAlert显示验证警报,但代码如下,但它只在firefox中无法正常工作。警报框开始出现然后消失,Javascript基本挂起。代码如下:
jQuery(' .enroll-button')。click(function(e){
e.preventDefault();
var l = Ladda.create(this);
var tLeadType = jQuery('input[name="radioOpt"]:checked', '#sellBuyOpt').val()
var nSourceId = 0;
<?php if (isset($_GET["nsourceid"])){
echo 'nSourceId = '.$_GET["nsourceid"];
} ?>
var inputElements = [];
var tFirstName = jQuery("#firstName");
var tLastName = jQuery("#lastName");
var tEmailAddress = jQuery("#email");
var tCity = jQuery("#city");
var tState = jQuery("#state");
var tPhoneNumber = jQuery("#phoneNumber");
inputElements.push(tFirstName);
inputElements.push(tLastName);
inputElements.push(tEmailAddress);
inputElements.push(tCity);
inputElements.push(tState);
inputElements.push(tPhoneNumber);
//validations
var validated = true;
for(var i= 0; i < inputElements.length; i++){
if(inputElements[i].val().trim()===""){
inputElements[i].val("");
inputElements[i].attr("placeholder","This is required");
inputElements[i].css("border-color","#A33643");
validated = false;
}
if(i == 2){
var res = validateEmail(inputElements[i].val());
if(!res){
inputElements[i].val("");
inputElements[i].attr("placeholder","Valid Email required");
inputElements[i].css("border-color","#A33643");
validated = false;
}
}
if(i == 4 && inputElements[i].val() == "Select a state"){
sweetAlert("Oops...", "Please select a valid state!", "error");
validated = false;
}
if(i == 5 && !simpleClientPhoneValidator(inputElements[i].val())){
inputElements[i].val("");
inputElements[i].attr("placeholder","Invalid Phone Number");
inputElements[i].css("border-color","#A33643");
validated = false;
}