Live Helper Chat support forum.. Forum is locked. New place for questions - Github Discussions

You are not logged in.

Announcement

#1 2017-09-21 05:58:48

Radhika
Member
Registered: 2017-09-21
Posts: 1

Jquery inside javascript function

In a jsp form validation page, I am checking whether a name is already exists or not.If it exists ,a suitable message is displaying, saying "Name already exists!!".
But inspite of that message ,the form is submitting if i click the submit button.

I'm a newbie to jquery, please help.


This is my js page:

function groupValidator() {
    var fv = true;
    var groupNamereg = /^[a-zA-Z]+[\d ]*[\w ]*$/;
    var grpName = document.getElementById('groupName').value;
    var link = document.getElementsByName("link");
   
    if (!grpName.trim().match(groupNamereg)) {
        document.getElementById('gnError').innerHTML = "Group Name cannot have only numbers or special characters";
        fv = false;
    }
    if (grpName == "" || grpName == null) {
        document.getElementById('gnError').innerHTML = "Group Name cannot be empty";
        fv = false;
    }
   
    $('#groupName').blur(
            function(event) {
                var name = document.getElementById('groupName').value;
                var className = 'Group';
                $.get("checkNameExistence?name=" + name + "&className="
                        + className, function(responseText,status) {
                    alert(responseText);
                    alert(fv);
                    if(responseText.trim() == ""){
                       
                    }else{
                    fv = false;
                    $("#gnError").text(responseText);
                    alert(">>> : "+fv);                             //Here fv is false
                    }
                });
            });
   
    if (link[0].checked == false && link[1].checked == false) {
        document.getElementById('linkError').innerHTML = "Please select link type";
        fv = false;
    }
    alert(">>> fsdfsdff : "+fv);     // But how come here it changes to true
    return fv;
}

Offline

#2 2017-09-21 09:52:59

PeopleInside
Administrator
From: Italy
Registered: 2014-04-10
Posts: 4,046
Website

Re: Jquery inside javascript function

Hi Radhika,
welcome in the live helper chat support forum!

Here the support is limited and free about basic functions or questions.
Seems you need customize something and I think you will not find any help regarding this here as I cannot provide support about this.

There is maybe two way you can take,
the first is asking in some forum on the web where developers can help you,
the second is consider to ask for the commercial support: you can find more info regarding this on my forum signature.

Welcome on board and thank you for your interest in the live helper chat project!


lol PeopleInside - Live helper chat - free limited forum support!
wink For commercial support or GitHub [see FAQ here]
ops If you want to support this open source project, just donate [see support page]
glasses Something wrong with the forum? [contact a superhero]

Offline

Board footer