Display Client-Side alert if Server-Side validation fails

<xp:label id="label1">
		<xp:this.value><![CDATA[#{javascript:/** If there are any messages for this request, run the client-side JavaScript after the viewRoot response is completed **/
	if(facesContext.getMessages().hasNext()){
		var x="alert('THE DOCUMENT WAS NOT SAVED.\\n\\nAll required fields were not completed or they do not contain valid data.\\n\\nPlease review the fields and correct any errors.');";
		view.postScript(x);
	}}]]></xp:this.value>
</xp:label>





(8.5.3+ only) Paste this control into your XPage source to display a client-side alert if any server-side validations fail.

JavaScript (Server)
Russell Maher
December 14, 2011 12:37 AM
Rating
1,069

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.



No comments yetLogin first to comment...