0

Is it ok, to validate some data using jquery? I am working on a plugin which has repeater fields in widgets, so my plan was to convert all repeater field data in json when user clicks on save button. Data which i want to validate is zipcode and text fields. I am not sure, if this is allowed.

  • In my opinion. Yes you can use jQuery for validation. – BlueSuiter May 3 '17 at 12:42
0

Yes, you can validate data using jquery before submitting form. There is a way custom way to do that by checking the fields value length

`$(document).ready(function(){
    $("#form").submit(function(){
        var field_value = $('input[name="some_name"]').val();
        if(field_value.length>0){
           return true;
        } else{
           return false;
        }
    });
});`

Or you can use a jquery validation library.

https://jqueryvalidation.org/

  • HI alok, Thanks for your suggestion, but my question is, Does WP allows to validate data using jquery. I want to upload my plugin on WP repo? – Pratik Deshmukh May 3 '17 at 13:04
  • Yes, WP allows to use jquery to validate data for uploading to WP repo. – Alok Shrestha May 4 '17 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.