• Resolved kusalo

    (@kusalo)


    I am enjoying working through the generous offering of snippets but can’t find ‘exactly’ what I want. Specifically, I have implemented the ‘limit characters’ snippet OK but it throws an alert() which is not so aesthetic. I would like to present the error in a more tidy way.

    I tried to cross this with: my_wpforms_process_validate_phone
    but can’t seem to get my ‘hack’ working. I have tried to adapt a few other snippets to get a direct error-entry for the specific field.

    My current approach is to set a hidden div and, instead of the alert, position the div adjacent to the relevant field with the appropriate msg. I have tolerable jQuerry exp. but need the field id to do this.

    Again, I have tried working with: wpf_dev_field_properties
    but… one , or ; wrong and it don’t work.
    It doesn’t ??

    There may be an existing snippet – and I have really looked – to
    1 – customise error messages for specific fields or,
    2 – get the ID for an active field; to position an error-div or,
    3 – some other suggestion you might have.

    Thank you for your time.
    Kusalo

    • This topic was modified 1 year, 7 months ago by kusalo.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @kusalo,

    We’d be happy to help!

    It seems that you are using the paid version of WPForms. If you have an active license subscription with us, could you please submit a support ticket through the WPForms account dashboard when you have a chance??

    From there, our support team will be able to take a closer look at your request. 

    Thanks!

    Thread Starter kusalo

    (@kusalo)

    Hi Nikhil,

    I have not long started with WP – after years of hand coding – and am still exploring many options; and still in the sandbox stage. So, no, I am not yet pro.
    What I am specifically working on is:
    https://wpforms.com/developers/how-to-restrict-special-characters-from-a-form-field/
    My question was about replacing the (ugly) alert()
    I have tried various approaches and settled on as the best match.

    //intro as per original +
    if (!regex.test(key)) { 
    				myField = this.id; // = wpforms-myFormID-field_myFieldID-container
    				myfieldClean = myField.replace('-container','') // = wpforms-myFormID-field_myFieldID	
    if ($('.akError').length < 1 ) { 
    	$("[id="+myfieldClean+"]").after('<div class="akError" style="font-size:13px !important;">Use only the character listed above. A-Z a-z etc.</div>'); }
    		setTimeout(function () {$('.akError').remove() },2555);
                    e.preventDefault();
                    return false;
                }

    The same can be repeated for the paste function.

    I tried the div position:absolute approach and it works well enough but thought that the above is consistent with your styling.

    This has taken me a while. I wonder if others might use it? Perhaps modify the original snippet?

    • This reply was modified 1 year, 7 months ago by kusalo. Reason: typo
    • This reply was modified 1 year, 7 months ago by kusalo.

    Hi @kusalo Thanks for sharing the code and suggestion. I will surely give a heads up to the concerned team for this one.

    Thank you so much and have a good one ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘custom error msg positioning for specific ID’ is closed to new replies.