Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
on button submit javascript return false but it's not working at all. I have searched the solution and tried many solution but still not working.


C#
@using (Html.BeginForm("Add", "EmailTemplate", FormMethod.Post, new { id = "submitForm", enctype = "multipart/form-data",onsubmit = "javascript:return fnDuplicatecheck()"}))
        {

<input type="submit" value="Save" class="float-r btn-gray1" />
}


javascript



function fnDuplicatecheck() {
        loader();
        debugger;
        var TemplateName = document.getElementById('TemplateName').value;
        $.ajax({
            url: '@Url.Action("GetDuplicateTemplate", "EmailTemplate")',
            type: "GET",
            data: { TemplateName: TemplateName },
            success: function (data) {
                debugger;
                if (data == "Yes") {
                    $("#popup_ok").click();
                    jAlert("Template Name Already Exist", "Error");
                    return false;
                }
                else {
                    $("#popup_ok").click();
                    return false;
                }
            }
        });
    }


Thanks.
Posted
Updated 13-Jul-15 0:05am
v2
Comments
Kornfeld Eliyahu Peter 13-Jul-15 6:27am    
What do you mean 'not working'?
What do you try to do?

1 solution

Use the debugging tools in the browser to narrow the issue down. Does the correct html get written out in the form tag? Does your function every get called? Are there errors in the console? What happens when you step through the code line by line? One potential issue is that if your js is an in external js file then what you have isn't going to work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900