I need to use a custom Update/Submit button (on a Details form) because I need to use rules to show/hide some required fields. If the fields are set to 'Required' they cannot be hidden using Rules. So I unchecked the 'Required' box for those fields. I am using a custom Update button (hiding in Styles the default one) so I can put checking code in before the record is Updated, to make sure those fields aren't null.
I don't know exactly how to code this because the button type needs to be "button" (instead of "submit") so it will run the checking code. If neither of the fields are null then I need the button to run "submit" code. If either of the fields are blank I need an alert box to show and no "submit" code to run.
1) does anyone know how to put in an 'else' statement that changes the button type to "submit" so if fieldA and fieldB are not null it submits?
2) does anyone know how to put an 'if both FieldA AND FieldB are NOT null then "submit"? I need it to only submit if both fieldA AND fieldB are not null. I'm not sure of the syntax for that.
Here's the code I'm using so far- thanks for any help.
<divstyle="text-align: center;"><inputclass="cb_custom_btn"type="button"onclick="myFunction()"value="Check Required & Update"/><script>function myFunction(){var v_fielda = document.getElementById("EditRecordFieldA").value;if(!isNaN(v_fielda)){
alert("Field A is required");}var v_fieldb = document.getElementById("EditRecordFieldB").value;if(!isNaN(v_fieldb)){
alert("Field B is required");}--// here I need something that does "if both fieldA AND fieldB = not null then run "submit" (but do NOT run "submit" if either FieldA OR FieldB = null) //--}</script></div>
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.
Question
DesiLogi
Hello,
I need to use a custom Update/Submit button (on a Details form) because I need to use rules to show/hide some required fields. If the fields are set to 'Required' they cannot be hidden using Rules. So I unchecked the 'Required' box for those fields. I am using a custom Update button (hiding in Styles the default one) so I can put checking code in before the record is Updated, to make sure those fields aren't null.
I don't know exactly how to code this because the button type needs to be "button" (instead of "submit") so it will run the checking code. If neither of the fields are null then I need the button to run "submit" code. If either of the fields are blank I need an alert box to show and no "submit" code to run.
1) does anyone know how to put in an 'else' statement that changes the button type to "submit" so if fieldA and fieldB are not null it submits?
2) does anyone know how to put an 'if both FieldA AND FieldB are NOT null then "submit"? I need it to only submit if both fieldA AND fieldB are not null. I'm not sure of the syntax for that.
Here's the code I'm using so far- thanks for any help.
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
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.