Corrected script.js
:
$(function() {
$("#username_error_message").hide();
$("#email_error_message").hide();
$("#phone_message").hide();
$("#company_error_message").hide();
$("#comment_error_message").hide();
var error_username = false;
var error_email = false;
var error_phone = false;
var error_company = false;
var error_comment = false;
$("#form_username").focusout(function() {
check_username();
});
$("#form_email").focusout(function() {
check_email();
});
$("#form_phone").focusout(function() {
check_phone();
});
$("#form_company").focusout(function() {
check_company();
});
$("#form_comment").focusout(function() {
check_comment();
});
function check_username() {
var username_length = $("#form_username").val().length;
if (username_length < 5 || username_length > 20) {
$("#username_error_message").html("name 5-20 characters");
$("#username_error_message").show();
error_username = true;
} else {
$("#username_error_message").hide();
}
}
function check_email() {
var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
if (pattern.test($("#form_email").val())) {
$("#email_error_message").hide();
} else {
$("#email_error_message").html("Invalid email address");
$("#email_error_message").show();
error_email = true;
}
}
function check_phone() {
var phone_length = $("#form_phone").val().length;
if (phone_length < 8) {
$("#phone_error_message").html("phone 9-10 characters");
$("#phone_error_message").show();
error_phone = true;
} else {
$("#phone_error_message").hide();
}
}
function check_company() {
var company_length = $("#form_company").val().length;
if (company_length < 5 || company_length > 20) {
$("#company_error_message").html("Company name 5-20 characters");
$("#company_error_message").show();
error_company = true;
} else {
$("#company_error_message").hide();
}
}
function check_comment() {
var comment_length = $("#form_comment").val().length;
if (comment_length < 10 || comment_length > 20) { // Corrected 'coomment_length' to 'comment_length'
$("#comment_error_message").html("Should be between 10-20 characters");
$("#comment_error_message").show();
error_comment = true;
} else {
$("#comment_error_message").hide();
}
}
$("#registration_form").submit(function() {
error_username = false;
error_email = false;
error_phone = false;
error_company = false;
error_comment = false;
check_username();
check_email();
check_phone();
check_company();
check_comment();
if (error_username == false && error_email == false && error_phone == false && error_company == false && error_comment == false) {
return true;
} else {
return false;
}
});
});
Fixes made:
-
Fixed typo in
check_comment
function (changedcoomment_length
tocomment_length
). -
Ensured the form submission check (
$("#registration_form").submit()
) properly checks all validation errors.
Once these fixes are applied, the form should work correctly without validation errors. Let me know if you need further adjustments!
Oracle OSB Training
OSB Online Training Hyderabad
osb certification training
soa training
oracle soa 12c training
tableau online training