Title: Custom error handling
Last modified: August 30, 2016

---

# Custom error handling

 *  Resolved [new_B](https://wordpress.org/support/users/new_b/)
 * (@new_b)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/custom-error-handling/)
 * Thanks again for your useful plugin.
 * To improve both usability and accessibility, is there a way to customize error
   validation/messages when the branch locator form is submitted, without hacking
   the plugin code directly?
 * Right now, it just highlights it red.
 * Thanks.
 * [https://wordpress.org/plugins/wp-store-locator/](https://wordpress.org/plugins/wp-store-locator/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/custom-error-handling/#post-6837784)
 * Not at the moment. But not sure how to improve accessibility for that issue. 
   I could have JS dynamically add text somewhere saying something about the problem,
   but would screen readers pick that up if it’s dynamically?
 *  Thread Starter [new_B](https://wordpress.org/support/users/new_b/)
 * (@new_b)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/custom-error-handling/#post-6837797)
 * Thanks, Tijmen. According to [http://webaim.org/techniques/formvalidation/#form](http://webaim.org/techniques/formvalidation/#form),
   there should be a none JS fallback.
 * Would it be possible to add a form action? “Use a true URL action value for the
   form. You can still invoke client-side validation, and it would be processed 
   first if scripting is enabled”
 * It just occurred to me that there is no <form reference in the default non JS
   code. (This may also explain the Search submit button not working when JS is 
   disabled.)
 *     ```
       <div class="wpsl-search wpsl-clearfix wpsl-filter">
       		<div id="wpsl-search-wrap">
       			<div class="wpsl-input">
       				<div><label for="wpsl-search-input">Your location</label></div>
       				<input autocomplete="off" id="wpsl-search-input" type="text" value="" name="wpsl-search-input" />
       			</div>
       			<div class="wpsl-select-wrap">
       				<div id="wpsl-radius">
       					<label for="wpsl-radius-dropdown">Search radius</label>
       					<select autocomplete="off" id="wpsl-radius-dropdown" name="wpsl-radius">
       						<option value="10">10 km</option><option value="25">25 km</option><option selected="selected" value="50">50 km</option><option value="100">100 km</option><option value="200">200 km</option><option value="500">500 km</option>
       					</select>
       				</div>
       				<div id="wpsl-results">
       					<label for="wpsl-results-dropdown">Results</label>
       					<select autocomplete="off" id="wpsl-results-dropdown" name="wpsl-results">
       						<option selected="selected" value="25">25</option><option value="50">50</option><option value="75">75</option><option value="100">100</option>
       					</select>
       				</div>
       			</div>
       ```
   
 *  Thread Starter [new_B](https://wordpress.org/support/users/new_b/)
 * (@new_b)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/custom-error-handling/#post-6837798)
 * Would it be possible to use the “<form” tag and add an action(or just leave action
   blank to default it to the current page)? [http://webaim.org/techniques/formvalidation/#form](http://webaim.org/techniques/formvalidation/#form)
 * I just realized the existing (non JS) code doesn’t use the “<form” tag. This 
   also explains why the Search submit button doesn’t work when JS is disabled.
 * Here’s an example (from Joe Dolson, an accessibility expert) -https://www.joedolson.
   com – try out the sign up form on the right column. It works with JS disabled.
 * Is there currently a way to override these without hacking the plugin code (if
   you don’t have the time to do this). Otherwise, let me know if I can be of assistance
   to speed up this process.
 * We would really like to use this handy plugin but accessibility is a must. Thanks.
 *  Thread Starter [new_B](https://wordpress.org/support/users/new_b/)
 * (@new_b)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/custom-error-handling/#post-6837801)
 * FYI: JS, forms, and accessibility: [http://a11yproject.com/posts/myth-screen-readers-dont-use-javascript/](http://a11yproject.com/posts/myth-screen-readers-dont-use-javascript/)
   and [http://www.w3.org/TR/WCAG20-TECHS/client-side-script.html](http://www.w3.org/TR/WCAG20-TECHS/client-side-script.html)
 * ***After doing some more research, to fix the validation issue, in addition to
   adding the <form tags, the required Location input field should use HTML 5 required
   attributed and aria-required as well for more browser support. [https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-required_attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-required_attribute)
 *  Thread Starter [new_B](https://wordpress.org/support/users/new_b/)
 * (@new_b)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-error-handling/#post-6837910)
 * *Note: I managed to get required field error validation to work by overriding
   the default.php template.
 * Would it be possible when you have the time to integrate this as the default 
   code? I think it would be handy for everyone to have it more accessible by default.
   Thanks.
 * I added `required` and `aria-required="true"` to the location input field code.
 * I also added `<form>` and `</form>` around the whole form to use the default 
   HTML 5 and ARIA aria handling related to the above.
 *  Plugin Author [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-error-handling/#post-6837917)
 * Can you email me the template you have now with the form and aria code to tijmen
   at wpstorelocator.co?
 *  Thread Starter [new_B](https://wordpress.org/support/users/new_b/)
 * (@new_b)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-error-handling/#post-6837924)
 * Unfortunately, it’s more accessible but the functionality is now broken. Perhaps,
   it’s too dependent on the JS (as opposed to HTML form elements, submit button,
   for action, etc.) and stops functioning. When I hit “Submit”, it no longer returns
   any results, as expected.
 * I’m currently still looking into it.
 *  Thread Starter [new_B](https://wordpress.org/support/users/new_b/)
 * (@new_b)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-error-handling/#post-6837926)
 * I will e-mail you what I have now.
 *  Thread Starter [new_B](https://wordpress.org/support/users/new_b/)
 * (@new_b)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-error-handling/#post-6838037)
 * FYI: Here’s what I ended up with. Adding the <form, etc… just caused more problems
   than not and stopped the geocoding, etc. from happening properly.
 * To make the existing validation more user-friendly and accessible, I added an
   alert after the location field is highlighted (which indicates the field needs
   to be filled out).
 * wpsl-gmap.min.js – function searchLocationBtn
 *     ```
       if ( !$( "#wpsl-search-input" ).val() ) {
       	$( "#wpsl-search-input" ).addClass( "wpsl-error" ).focus();
               // Add an alert to make validation more usable and accessible.
               alert("Please fill out the location field.");
       ...
       ```
   
 * The above would need to be adjusted to work with multilingual (e.g., WPML) text.
 * Would it be possible to add this without having to hack the plugin code?
 * Thanks again.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Custom error handling’ is closed to new replies.

 * ![](https://ps.w.org/wp-store-locator/assets/icon-256x256.jpg?rev=1007784)
 * [WP Store Locator](https://wordpress.org/plugins/wp-store-locator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-store-locator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-store-locator/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-store-locator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-store-locator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-store-locator/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [new_B](https://wordpress.org/support/users/new_b/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/custom-error-handling/#post-6838037)
 * Status: resolved