bookish Posted January 15, 2015 Report Share Posted January 15, 2015 Hi! May I ask how to disable a form if in the field for specifying a special diet the person places a special room request. How can the form be disabled if the person places words such as "room", "bedroom", "floor"? The error message should be "Please specify your diet requirement." Thanks in advance for your help. lbyirsva53 1 Quote Link to comment Share on other sites More sharing options...
Jan Posted January 15, 2015 Report Share Posted January 15, 2015 Hi bookish, Can you use drop-down lists instead of input fields? You can use Lookup tables with variants of special diets and special room requests. You can look for some words in the field with the following code: <SCRIPT LANGUAGE="JavaScript"> function check_text() { var text_for_checking = document.getElementById("InsertRecordtext").value; var wrong_answer = false; if (text_for_checking.search("room")!=-1) {wrong_answer = true}; if (text_for_checking.search("floor")!=-1) {wrong_answer = true}; if (wrong_answer) { alert("Please specify your diet requirement."); return false; } } document.getElementById("caspioform").onsubmit=check_text; </SCRIPT> Please, enter the name of your field instead of text in the var text_for_checking = document.getElementById("InsertRecordtext").value; You can add as many words as you wish, just copy the line if (text_for_checking.search("room")!=-1) {wrong_answer = true}; and enter your word instead of "room". To use a Java Script code, please add a Header&Footer element, select the Footer element, then click the Source button, and then enter a code. I hope it helps. bookish 1 Quote Link to comment Share on other sites More sharing options...
bookish Posted January 15, 2015 Author Report Share Posted January 15, 2015 That's brilliant, Jan. Thanks a million!!! Quote Link to comment Share on other sites More sharing options...
Jan Posted January 15, 2015 Report Share Posted January 15, 2015 You are very welcome! Quote Link to comment Share on other sites More sharing options...
bookish Posted March 8, 2015 Author Report Share Posted March 8, 2015 HI! How would I edit the code if the form is an UPDATE form? Thanks for your help. Quote Link to comment Share on other sites More sharing options...
Jan Posted March 10, 2015 Report Share Posted March 10, 2015 Hi bookish, Please change "InsertRecord" to "EditRecord" in the line: var text_for_checking = document.getElementById("EditRecordtext").value; You can read Details in the Guide. I hope, it helps! Quote Link to comment Share on other sites More sharing options...
bookish Posted March 28, 2015 Author Report Share Posted March 28, 2015 Thank you, Jan. It's very helpful. I am sorry for late feedback. Quote Link to comment Share on other sites More sharing options...
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.