• Resolved Jan

    (@jan3)


    Hi,

    I would like to make (at least) some client-site validation of whether a name field consists of letters and a phone field consists of digits. Any idea how to do that with the shortcodes that are produces by the plugins booking form?

    Thanks Jan

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author wpdevelop

    (@wpdevelop)

    Hello.
    Currently Booking Calendar support onky validation for the “email field” and for required fields”. Other form fields validations require customization, and does not support in actual versions of Booking Calendar. Sorry.

    For example, if you need to check that visitor enter only digits for phone number, you can make customization for additional checking about it.

    Please open this file ../{Booking Calendar Folder}/js/client.js

    ( you can check how to edit files in WordPress menu in this article http://wpbookingcalendar.com/faq/how-edit-file-in-wp-menu/ )

    then find this code:

    
                /*if ( element.name == ('phone'+bk_type) ) {
                    // we validate a phone number of 10 digits with no comma, no spaces, no punctuation and there will be no + sign in front the number - See more at: http://www.w3resource.com/javascript/form/phone-no-validation.php#sthash.U9FHwcdW.dpuf
                    var reg =  /^\d{10}$/;
                    var message_verif_phone = "Please enter correctly phone number";
                    if ( inp_value != '' )
                        if(reg.test(inp_value) == false) {showErrorMessage( element , message_verif_phone);return;}
                }*/
    

    and replace it to this code:

    
                if ( element.name == ('phone'+bk_type) ) {
                    // we validate a phone number of 10 digits with no comma, no spaces, no punctuation and there will be no + sign in front the number - See more at: http://www.w3resource.com/javascript/form/phone-no-validation.php#sthash.U9FHwcdW.dpuf
                    var reg =  /^\d{10}$/;
                    var message_verif_phone = "Please enter correctly phone number";
                    if ( inp_value != '' )
                        if(reg.test(inp_value) == false) {showErrorMessage( element , message_verif_phone);return;}
                }
    

    Please do not forget to clear browser cache before testing these changes.

    Disclaimer. Unfortunately we can not start, right now, some personal customization or custom development, because almost have no free time.
    Check more about new features here https://wpbookingcalendar.com/faq/need-new-feature/
    Thank you for understanding.
    Please note, if you will modify the source code of the Booking Calendar, we will not guaranteed the correct work of plugin and do not support it.
    Kind Regards.

    Thread Starter Jan

    (@jan3)

    Thanks for your quick, valuable response.

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

The topic ‘How to validate input fields?’ is closed to new replies.