Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Stuck at Finishing Line

vishalonnevishalonne Posts: 6Member
I have made lots of changes in my code and I'm almost reched at the finish point but I stuck at finish line. Error checking is working fine but if there is no error then after clicking on submit button insertform.php page is not opening (means Action attribute of form tag is not working) please help me in solving this -
This the form.php page where validation is happening -
[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Your Valuable Suggestion







<[color=Red][b]form id="form_453570" class="appnitro" name="registration" method="post" action="insertform.php" onSubmit="return formValidation(this)">[/b][/color]


































[/code]
Here is the code of registration.js
[code]function formValidation()
{
var fn = document.registration.element_12;
var ln = document.registration.element_13;
var sx = document.registration.element_11;
var sn = document.registration.element_1;
if(fname_validation(fn,5)){
if(lname_validation(ln,5)){
if(ValidateEmail(em)){
if(validsex(sx)){
if(validSchoolName(sn)){
}
}
}
}
}
return false;
}
function fname_validation(fn,mx){
var letters = /^[A-Za-z]+$/;
var fn_len = fn.value.length;
if (fn_len == 0 || fn_len < mx) {
document.getElementById('fnTextBox').innerHTML = "Enter your First name/ Minimum length is 5 characters ";
fn.focus();
return false;
}
if(fn.value.match(letters)) {
return true;
}
else {
document.getElementById('fnTextBox').innerHTML = "Name must not contain other than alphabet";
fn.focus();
return false; //alert("User Id should not be empty / length be between "+mx+" to "+my);
}
return true;
}

function lname_validation(ln,mx){
var letters = /^[A-Za-z]+$/;
var ln_len = ln.value.length;
if (ln_len == 0 || ln_len < mx) {
document.getElementById('lnTextBox').innerHTML = "Enter your Last name/ Minimum length is 5 characters ";
ln.focus();
return false;
}
if(ln.value.match(letters)){
return true;
}
else{
document.getElementById('lnTextBox').innerHTML = "Name must not contain other than alphabet";
ln.focus();
return false; //alert("User Id should not be empty / length be between "+mx+" to "+my);
}
return true;
}

function validsex(sx){
if(!(sx[0].checked || sx[1].checked)){
document.getElementById('sxRadio').innerHTML = "Select your Sex";
sx[0].focus();
return false;
}
return true;
}

function ValidateEmail(em){
var mailformat = /^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/;
if(em.value.match(mailformat)){
return true;
}
else{
document.getElementById('emTextBox').innerHTML = "Enter Valid EMail ID";
em.focus();
return false;
}
}

function validSchoolName(sn){
var sn_len = sn.value.length;
if (sn_len == 0){
document.getElementById('snTextBox').innerHTML = "Enter your School Name";
sn.focus();
return false;
}
return true;
}[/code]
For convinience both the files are uploaded.
thank you for any guidance.

Comments

  • sunlotussunlotus Posts: 55Member

    Hmmm... I'm a beginner too, but I usually test like this:

    Make the formValidation(){return true;} Let it just so and see if the form is sent. if yes, add only the first if in the formValidation function. If the form is sending, add the second if; if the form is sent again, add the next if. Maybe there is a problem in one of the functions that validate.

    you have these ifs in the

    formValidation(){f(fname_validation(fn,5))
    if(lname_validation(ln,5))
    if(ValidateEmail(em))
    if(validsex(sx))
    if(validSchoolName(sn))}
Sign In or Register to comment.