validate form input type file type using jquery validate plugin -


the following code: script code

<script type="text/javascript"> $(document).ready(function() {     $("#formelem").validate({          rules: {                dimage:{                 minlength:200                 }           }, messages: {                dimage:{                required: 'please select image!'               } ,          }            });  }); </script> 

html code

<form id="formelem" name="formelem" action="" method="post">   <input type="file" name="dimage" id="dimage" /> </form> 

i'm using jquery validate.js file client side validation. when create file above code it's not showing error message.

how should alert error message when user not selected file?

try this.

$(document).ready(function() {     $("#formelem").validate({         rules: {               dimage:{                 required: true                 }           },         messages: {             dimage:{                required: 'please select image!'               } ,         }            }); }); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -