Is there a way I can restrict the value of a number field in a form? I only want users to be able to submit values equal to or greater than a particular number, and I want the form to reject the input otherwise, and prompt them to re-enter the value.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Jennifer,
Thank you for getting in touch.
You will need to this with some custom javascript.
Can you provide me with a link to the form so that I can write the custom Javascript that is required to do this ?
Thanks,
Shane
Hi Shane!
Sure, the form is here: hidden link
I would like to restrict the "Years of Practice" fields (both start year and end year) to only accept values greater than or equal to 1700.
I will also need it to work on my edit form although I can probably just use similar code for both, and could add it myself.
Please let me know if you need more information.
Thank you!
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Jennifer,
It seems I need to log in to see the form.
I've enabled the private fields so that you can provide me with the login to view the form.
Thanks,
Shane
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Jennifer,
Here is the jQuery to help resolve this. Add it to the JS section of your form.
jQuery(document).ready(function() {
jQuery("input[name='wpcf-practice-start-year']").attr({
// substitute your own
"min" : 1700 // values (or variables) here
});
jQuery("input[name='wpcf-practice-end-year']").attr({
// substitute your own
"min" : 1700 // values (or variables) here
});
});
Please let me know if this helps.
Thanks,
Shane
That worked perfectly. Thank you!