We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Vaildation in aspx page using javascript

Thread ID:

Created:

Updated:

Platform:

Replies:

127256 Nov 7,2016 12:19 AM Nov 14,2016 07:44 AM JavaScript 7
loading
Tags: ejDropDownList
rajivgandhi
Asked On November 7, 2016 12:19 AM

 i pasted my code below ,getting  error on button click   Uncaught TypeError: Cannot read property 'form' of undefined(…) validationSynfucusion.js:2
<form id="custom">
<table>
<tr>
                    <td class="e-leftfields e-textlabel" style="width: 20%;">
                        Job Type:
                    </td>
                    <td style="width: 1%;">
                        <input type="text" id="ddlAddJobType" />
                        <span class="errmsg" ></span>
                    </td>
<td> <button type="submit" onclick="save()" id="btnsubmit" style="float: left; margin-left: 38%;
                margin-bottom: 10px;">
                Save</button></td>
</table> 
</form>
 <script type="text/javascript">
 $.validator.setDefaults({
            ignore: [], // to include hidden input validation   
            errorClass: 'e-validation-error', // to get the error message on jquery validation   
            errorPlacement: function (error, element) {
                $(element).closest("div.control").find("span.errmsg").append(error);
            } // to place error message   
        });   
var JobTypes=[{JobTypeDescription:"job",JobTypeID:"1"}]
   $('#ddlAddJobType').ejDropDownList({
                        dataSource: JobTypes,
                        fields: {
                            text: "JobTypeDescription",
                            value: "JobTypeID"
                        },
                         validationRules: {
                required: true
            },
            validationMessage: {
                required: "Select JobType value"
            },
                        watermarkText: "Select Job Type"
                        //                        htmlAttributes: {
                        //                            style: "border:1px solid red;"
                        //                        }
                    });
function save()
{
 $("custom").valid();
}

</script>

Karthikeyan Viswanathan [Syncfusion]
Replied On November 7, 2016 05:46 AM

Hi Rajiv Gandhi, 
 
  Thanks for contacting Syncfusion support. 
 
  We found that issue. In Save Method, You are selecting a  form element with wrong JQuery selector.  To resolve this issue need to include #  JQuery Selector (#custom) In before of your form ID. 
 
Please use the below code snippet: 
 
Code: 
 
<body> 
 
    <form id="custom"> 
 
        <table> 
            <tr> 
                <td class="e-leftfields e-textlabel" style="width: 20%;">Job Type: 
                </td> 
                <td style="width: 1%;"> 
                    <input type="text" id="ddlAddJobType" /> 
                    <span class="errmsg"></span> 
                </td> 
                <td> 
                    <button type="submit" onclick="save()" id="btnsubmit" style="float: left; margin-left: 38%; margin-bottom: 10px;"> 
                        Save</button></td> 
        </table> 
    </form> 
    <script type="text/javascript"> 
        $.validator.setDefaults({ 
            ignore: [], // to include hidden input validation    
            errorClass: 'e-validation-error', // to get the error message on jquery validation    
            errorPlacement: function (error, element) { 
                $(element).closest("form").append(error); 
            } // to place error message    
        }); 
        var JobTypes = [{ JobTypeDescription: "job", JobTypeID: "1" }] 
        $('#ddlAddJobType').ejDropDownList({ 
            dataSource: JobTypes, 
            fields: { 
                text: "JobTypeDescription", 
                value: "JobTypeID" 
            }, 
            validationRules: { 
                required: true 
           }, 
            validationMessage: { 
                required: "Select JobType value" 
            }, 
            watermarkText: "Select Job Type" 
            //                        htmlAttributes: { 
            //                            style: "border:1px solid red;" 
            //                        } 
        }); 
        function save() { 
             $("#custom").valid(); 
        } 
 
    </script> 
</body> 
</html> 
 
 
 
Regards, 
Karthikeyan V. 


rajivgandhi
Replied On November 7, 2016 07:14 AM

Hi Team
                    Again i'm getting error Uncaught TypeError: Cannot read property 'form' of undefined
    at n.fn.init.valid (validationSynfucusion.js:2:1167)

Prince Oliver [Syncfusion]
Replied On November 8, 2016 04:16 AM

Hi Rajivgandhi,   
  
Thanks for your update.   
  
We could not reproduce the error. Please ensure that you have used the proper JQuery selector for selecting the form, and also check your script references in your sample to find out whether you have included query validation plugin in your sample in a proper order based on dependencies. If the issue still persists, provide us issue reproducing sample.   
  
Regards,   
Prince 


rajivgandhi
Replied On November 11, 2016 12:18 AM

Him Team,
                         send  query validation plugin order 

Prince Oliver [Syncfusion]
Replied On November 11, 2016 05:23 AM

Hi Rajivgandhi,   
  
Thanks for your update.   
  
Refer the jQuery and EJ scripts in following order in your sample.   
  
1.       jQuery script   
2.       jQuery validation script   
3.       EJ web all script   
  
Note: If you are using any other jQuery scripts refer the above EJ script.   


  
Regards,   
Prince 


rajivgandhi
Replied On November 11, 2016 06:15 AM

Hi Team,
                           It's working html page only. not in aspx
                          Please provied content page in aspx .div in a content page

Prince Oliver [Syncfusion]
Replied On November 14, 2016 07:44 AM

Hi Rajivgandhi, 

Sorry for the inconvenience caused. 

Please find the below sample in aspx page. 

Regards, 
Prince

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;