Jump to content

Dynamically Color Submit Button

Recommended Posts

Hi yall,


I have a submission with a calculated value and a text field. I want to compare the value of these two fields - if the text field is greater than the calculated value, I want the color of the submit button to change. I was able to achieve this with JavaScript:



document.addEventListener('DataPageReady', function (event) {

var field1 = document.querySelector("#InsertRecordField1")
var calcfield = document.querySelector("input[name='cbParamVirtual1']")

field1.addEventListener('keyup', function (evt) {
if((Number(field1.value) > Number(calcfield.value))){
document.querySelector(".cbSubmitButton").style.background = "red";
document.querySelector(".cbSubmitButton").style.background = "blue";




Make sure you replace all instances of "Field1" with the name of the text field, and "Virtual1" with your corresponding virtual field with the calc value. Lastly, change the colors to your liking - replace "red" with the color you want your submit button to have if the text field is greater than the calc value, and "blue" with the color  you want your submit button to have if the text field is lessthan the calc value.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...