My client has asked to create a request form based on a list which records all the requests in SharePoint 2010.
- Only one column in the request list which is the default column created when the list is created. It has a column type of “Single line of Text”. This column can’t be deleted or changed to a different column type.
- Display that column as a muli-line text box rather than a single-line input box and have the message wrapped.
- Once the request is sent successfully from the form, display a message to the user “Request Sent!”
- The user can only enter 255 characters in the box as specified in the Request column in the list. Anything over 255 will be truncated straight away. The reason it’s set to 255 is because in the list, the column has “Maximum number of characters” set to 255.
- Once a request is submitted successfully, a message will pop up to indicate the user.
- If something accidently clicked the “Send” button without typing a message, an error message will pop up and the empty request won’t be added to the list.
- This web part can be reused by changing the field names in the script to match with the list. However, I haven’t tried with lists containing fields other than single/multiple line of text.
This article really got me started. Thanks so much!
Say if I have a contact form instead and I would like to get the user to receive a copy of their submitted message in their email, I can probably include the code in this article. (In theory)
If the form included a dropdown list, the code in this article may be useful.
Form based validation in js
The validation on the form is pretty lame. If someone just entered spaces in the text box, it would still submit the form successfully. So how can I have a better validation for a required field? And what if I have a email or number field, what validation would I need? You are welcome to post solutions/thoughts in the comment area.