I am converting a static theme to a wp-theme and I am working on forms with wpcf7 plugin. I am wondering how can I write this code with wpcf7 text tag.

<input type="text" name="name" id="name" value="" onchange="this.setAttribute('value',this.value);" required/>

All what I could do is this

[text* name id:name]

my question is how can I add onchange to this text input ?

  • Please ask this kind of question on the Stack overflow forum instead. The WordPress forum isn't for plugins related issues.
    – Aurovrata
    Commented Dec 13, 2020 at 17:25

1 Answer 1


The CF7 plugin does not give you access to the HTML markup formatting function of the field tags. So you need to capture the JavaScript event fired when the field is changed. To do this you can tag a script at the end of your form,

<label>[text* name id:name]</label>
<label>[text* surname id:surname]</label>
'use strict';
  $(document).ready( function(){
    $('form.wpcf7-form :input').change(function(e){
      var $field = $(e.target);
        case 'name': //text field name was changed.
          //do something.
        case 'surname': //text field surname was changed.
          //do something.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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