I am trying to make a placeholder text in an input field, but having a hard time making this work.
I tried within the js of the capture for
document.getElementsByName("toEmail").placeholder = "Email*"; but it doesn't get set. Any ideas?
Try inserting the following before the closing
</form> tag when editing the Smart Capture block's HTML:
<script> var formInputToEmail = document.getElementsByName('toEmail'); var placeholderToEmail = document.createAttribute('placeholder'); placeholderToEmail.value = 'Email*'; formInputToEmail.setAttributeNode(placeholderToEmail); </script>
The above code snippet assumes the following:
- "toEmail" is unique (i.e., no other input fields have this attribute value for