I cannot and don't want to use required attribute because it is giving me so many rerendering issues as my page has so many dynamic fields based on different conditions, I am attaching the sample code.
<apex:pageMessages/>
<apex:messages/>
<apex:pageBlock id= "pBlock">
<apex:pageBlockSection>
<apex:pageBlockSectionItem>
<div class="requiredInput">
<div class="requiredBlock"></div>
<apex:inputField value="{!selectValue}">
<apex:actionsupport event="onChange" action="check()" rerender="pBlock"/>
<apex:inputfield>
</div>
</apex:pageBlockSectionItem>
<apex:pageBlockSection>
<apex:pageBlock>
<apex:commandLink value= "submit" action = "SSave"/>
Here is my apex save method
public void SSave(){
insert t;(t is the instance)
}
And this is the Javascript I am using just to throw an alert when data is submitted
<script>
var ids = "{!t.id}";
if(ids.length!=0){
alert('Data submitted successfully');
}
</script>
When I write validation it's throwing exception, if I catch it the page remains still on submitting.( Field is of type picklist, I want the error to be displayed when user submits with a none value) Any help is much appreciated.