You need to sign in to do that
Don't have an account?
Alex Wong 4
How to achieve validation by jQuery in Visualforce?
I have seen this article and try to adopt this method.
Salesforce Form Validation Enhanced:
https://th3silverlining.com/2010/03/02/visualforce-form-validation-enhanced/
However, I do not know why I get nothing happen even I have followed the step. Here is my code:
Thanks for your help.
Salesforce Form Validation Enhanced:
https://th3silverlining.com/2010/03/02/visualforce-form-validation-enhanced/
However, I do not know why I get nothing happen even I have followed the step. Here is my code:
<apex:page standardController="Artist__c" extensions="extattachfile" showHeader="false" sidebar="false"> <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <style type="text/css"> h1 {font-size: 150%; font-weight: bold;} h2 {font-size: ;} p { width:100%; font-size: 120%; text-align: justify; text-justify: inter-word;} .reddot {color: red; font-size:120%;} .textarea { height:200px; width:300px; border-radius: 5px;} .url {width:300px;} .title {font-size:175%;} .standard {width: 310px;} @media only screen and (min-width: 900px) { /* For desktop: */ p { width:890px; font-size: 120%; text-align: justify; text-justify: inter-word;} } .color { background-color: #F7F6D2; -webkit-transition: all 1s ease; -moz-transition: all 1s ease; -o-transition: all 1s ease; transition: all 1s ease; } </style> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"/> <apex:includescript value="{!$Resource.jQuery}"></apex:includescript> <apex:includescript value="http://ajax.microsoft.com/ajax/jquery.validate/1.6/jquery.validate.min.js"></apex:includescript> </head> <script type="text/javascript"> $(document).ready(function() { $('[id$=artistform]').validate(); $('[id$=engname]').rules("add",{ required: true, }); $('[id$=email]').rules("add",{ required: true, email: true }); /* Customised the messages */ jQuery.validator.messages.required = "You better have entered a value.. or else!"; jQuery.validator.messages.equalTo = "No silly, you're supposed to type the same set of characters AGAIN."; }); </script> <apex:form styleclass="form" id="artistform"> <apex:pageBlock > <apex:pageMessages /> <div><b class="title">Artist Submission Form</b></div><br/> <br/> <h1>Artist / Group Information 表演者 / 團體資料</h1> <br/><br/> <br/> <div class="standard"> <h2 >Artist Name (English)</h2><br/> <apex:outputText styleClass="reddot" value="*"/> <apex:panelGroup styleClass="col02 requiredInput" layout="block"> <apex:panelGroup styleClass="requiredBlock" layout="block"/> <apex:inputField value="{!artist.Artist_Group_Name_English__c}" label="" id="engname"/> </apex:panelGroup> <br/> </div> <br/> <br/> <div class="standard"> <h2 >Artist Biography (English)</h2><br/> <apex:outputText styleClass="reddot" value="*"/> <apex:panelGroup styleClass="col02 requiredInput" layout="block"> <apex:panelGroup styleClass="requiredBlock" layout="block"/> <apex:inputField value="{!artist.Artist_Group_Biography_English__c}" label="" styleClass="textarea" id="engbio"/> </apex:panelGroup> <br/><br/> </div> <br/> <div class="heading"> <h1>Name and Roles of Group Members (if applicable)</h1> <br/><br/> </div> <br/> <div class="standard"> <h2>Name and Roles of Group Members</h2><br/> <h2>團體成員姓名及崗位</h2><apex:outputText styleClass="reddot" value=""/><br/> <apex:inputField value="{!artist.Member_Name_Role__c}" label="" styleClass="textarea"/><br/> <br/> </div> <br/> <div class="standard"> <h2 >Photo of Artist : max 3 attachments</h2><br/> <apex:outputText styleClass="reddot" value="*"/> <br/> <apex:panelGroup styleClass="col02 requiredInput" layout="block"> <apex:panelGroup styleClass="requiredBlock" layout="block"/> <apex:inputFile value="{!objAttachment.body}" fileName="{!objAttachment.name}" required="false" id="photo"/><br/></apex:panelGroup> <apex:inputFile value="{!objAttachment2.body}" fileName="{!objAttachment2.name}" required="false" /><br/> <apex:inputFile value="{!objAttachment3.body}" fileName="{!objAttachment3.name}" required="false" /> <br/><br/> </div> <br/> <div class="standard"> <h2>Website</h2><outputtext/><apex:outputText styleClass="reddot" value=""/><br/> <apex:inputField value="{!artist.Website__c}" label="" styleClass="url" id="web"/><br/> <br/> </div> <br/> <div class="standard"> <h2 >Facebook</h2><apex:outputText styleClass="reddot" value=""/><br/> <apex:inputField value="{!artist.Facebook__c}" label="" styleClass="url" id="facebook"/><br/> <br/> </div> <br/> <div class="standard"> <h2 >SoundCloud</h2><apex:outputText styleClass="reddot" value=""/><br/> <apex:inputField value="{!artist.SoundCloud__c}" label="" styleClass="url" id="soundcloud"/><br/> <br/> </div> <br/> <div class="standard"> <h2 >YouTube</h2><apex:outputText styleClass="reddot" value=""/><br/> <apex:inputField value="{!artist.YouTube__c}" label="" styleClass="url" id="youtube"/> <br/> </div> <br/><br/> <div class="standard"> <h2>Technical Rider : max 1 attachment</h2><br/> <apex:outputText styleClass="reddot" value=""/><br/> <apex:inputFile value="{!objAttachmentt.body}" fileName="{!objAttachmentt.name}" /><br/> </div> <br/> <div class="standard"> <h2>Stage Plot : max 1 attachment</h2> <br/> <apex:outputText styleClass="reddot" value=""/><br/> <apex:inputFile value="{!objAttachments.body}" fileName="{!objAttachments.name}" required="false" /><br/><br/> </div> <br/> <div class="heading"> <h1>Contact Information</h1> <br/><br/> </div> <br/> <div class="standard"> <h2>Contact Person</h2><apex:outputText styleClass="reddot" value="*"/><br/> <apex:panelGroup styleClass="col02 requiredInput" layout="block"> <apex:panelGroup styleClass="requiredBlock" layout="block"/> <apex:inputField value="{!artist.Contact_Person__c}" label="" id="contactperson"/> <br/> </apex:panelGroup> </div> <br/> <div class="standard"> <h2 >Contact No.</h2><apex:outputText styleClass="reddot" value="*"/><br/> <apex:panelGroup styleClass="col02 requiredInput" layout="block"> <apex:panelGroup styleClass="requiredBlock" layout="block"/> <apex:inputField value="{!artist.Contact_Number__c}" label="" id="contactno"/> <br/> </apex:panelGroup> </div> <br/> <div class="standard"> <h2>Email</h2><apex:outputText styleClass="reddot" value="*"/><br/> <apex:panelGroup styleClass="col02 requiredInput" layout="block"> <apex:panelGroup styleClass="requiredBlock" layout="block"/> <apex:inputField value="{!artist.Email__c}" label="" id="email"/> <br/> </apex:panelGroup> </div> <br/> <br/> <div> <apex:commandButton action="{!save}" value="Save"/> </div> <script> var addclass = 'color'; var $cols = $('.standard').click(function(e) { $cols.removeClass(addclass); $(this).addClass(addclass); }); </script> </apex:pageBlock> </apex:form> <apex:pageMessages /> </apex:page>
Thanks for your help.
You can get more information here in below links.
http://sfdcsrini.blogspot.com/2016/04/jquery-validatior.html
https://th3silverlining.com/2010/03/02/visualforce-form-validation-enhanced/
For more help share your issues.
Regards,
Scott Haleo
Hytechpro
All Answers
You can get more information here in below links.
http://sfdcsrini.blogspot.com/2016/04/jquery-validatior.html
https://th3silverlining.com/2010/03/02/visualforce-form-validation-enhanced/
For more help share your issues.
Regards,
Scott Haleo
Hytechpro
Yes
Using jquery you can put your custom validation message on field.
Thanks. :)
Scott Haleo
Try to customize as per this below link
http://sfdcsrini.blogspot.com/2016/04/jquery-validatior.html.
And you can add error message with in script.
Regards,
Scott Haleo