Multiple validation on a form using javascript
Hello.
I have a form w/multiple fields. I want to validate all of these fields when user hit 'submit'. Below is my javascript, what do i have to do/change in order for this script to work in HTML DB? Please advise. Thank you very much.
-Anh
function validation(form) {
var email = form.email.value.toUpperCase();
var email_length = form.email.value.length;
if (form.email.value == "") {
alert("Error!\nAll fields must be entered.");
form.email.focus();
return false;
if (form.cost_center.value == "") {
alert("Error!\nAll fields must be entered.");
form.cost_center.focus();
return false;
if (form.cost_center.value.length < 4) {
alert("Error!\nWrong cost center, cost center has to be at least 4 digits.");
form.cost_center.focus();
return false;
if (form.email.value.length <= 11) {
alert("Error!\nInvalid email format.\nValid example: [email protected]");
form.email.focus();
form.email.select();
return false;
else {
if ((email.substring(email_length -11, email_length)) != "@ORACLE.COM") {
alert("Error!\nInvalid email format.");
form.email.focus();
form.email.select();
return false;
form.cost_center.value = form.cost_center.value.toUpperCase();
return true;
Have a look here: http://forums.adobe.com/thread/448695?tstart=0.
I hope it helps.
Ben
Similar Messages
-
I would like to perform certain validations when user clicks the email button. However, I am unable to enter any JavaScript in the click event. This event is disabled.
Is there a way to email a form using JavaScript (not through the Submit tab)? This way I can run the validations in the click event, before emailing the form.
Any other suggestions are welcome.
Thanks
AdityaAditya,
A common solution is to use two buttons. Add a Email Submit Button object and define the presence as 'invisible'. Let's name the object 'EmailSubmitBtn'. Add a Button object and change the caption to 'Email'. Let's call the object 'EmailBtn'. One the 'EmailBtn' click event perform the required validations and then call the click event on the 'EmailSubmitBtn'. You call the 'EmailSubmitBtn' click event as follows:
form1.subform1.EmailSubmitBtn.execEvent("click");
Steve -
How to seperate current page fields in a pdf form using javascript
Hi,
Is that possible to seperate current page fields(textbox, Chesckbox) in a pdf form using javascript.
I have coding to get all the fields in a pdf form. But i want to take CURRENT PAGE alone.
Please help me out.
Thanks and regards,
ChristyHi try67,
Thanks for your support.
I got the result.
Thanks and Regards,
Christy -
hi friends
i am trying to set peoples or groups field in sharepoint list form with current user login name
here my code
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
<script type="text/javascript">
$(document).ready(function NewItemView () {
var currentUser;
if (SP.ClientContext != null) {
SP.SOD.executeOrDelayUntilScriptLoaded(getCurrentUser, 'SP.js');
else {
SP.SOD.executeFunc('sp.js', null, getCurrentUser);
function getCurrentUser() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
currentUser = web.get_currentUser();
context.load(currentUser);
context.executeQueryAsync(onSuccessMethod, onRequestFail);
function onSuccessMethod(sender, args) {
var account = currentUser.get_loginName();
var accountEmail = currentUser.get_email();
var currentUserAccount = account.substring(account.indexOf("|") + 1);
SetAndResolvePeoplePicker("requester",account);
// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
alert('request failed' + args.get_message() + '\n' + args.get_stackTrace());
function SetAndResolvePeoplePicker(fieldName, userAccountName) {
var controlName = fieldName;
var peoplePickerDiv = $("[id$='ClientPeoplePicker'][title='" + controlName + "']");
var peoplePickerEditor = peoplePickerDiv.find("[title='" + controlName + "']");
var spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];
peoplePickerEditor.val(userAccountName);
spPeoplePicker.AddUnresolvedUserFromEditor(true);
</script>
but it is not working
please help meHi,
According to your post, my understanding is that you wanted to set "peoples or groups" field with current user "login name" in SharePoint list form using JavaScript.
To set "peoples or groups" field with current user "login name”, you can use the below code:
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
<script type="text/javascript">
function SetPickerValue(pickerid, key, dispval) {
var xml = '<Entities Append="False" Error="" Separator=";" MaxHeight="3">';
xml = xml + PreparePickerEntityXml(key, dispval);
xml = xml + '</Entities>';
EntityEditorCallback(xml, pickerid, true);
function PreparePickerEntityXml(key, dispval) {
return '<Entity Key="' + key + '" DisplayText="' + dispval + '" IsResolved="True" Description="' + key + '"><MultipleMatches /></Entity>';
function GetCurrentUserAndInsertIntoUserField() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
this._currentUser = web.get_currentUser();
context.load(this._currentUser);
context.executeQueryAsync(Function.createDelegate(this, this.onSuccess),
Function.createDelegate(this, this.onFailure));
function onSuccess(sender, args) {
SetPickerValue('ctl00_m_g_99f3303a_dffa_4436_8bfa_3511d9ffddc0_ctl00_ctl05_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_UserField', this._currentUser.get_loginName(),
this._currentUser.get_title());
function onFaiure(sender, args) {
alert(args.get_message() + ' ' + args.get_stackTrace());
ExecuteOrDelayUntilScriptLoaded(GetCurrentUserAndInsertIntoUserField, "sp.js");
</script>
More information:
http://alexeybbb.blogspot.com/2012/10/sharepoint-set-peoplepicker-via-js.html
Best Regards,
Linda Li
Linda Li
TechNet Community Support -
Hello,
I am using jdev 11.1.1.6
I want to know how to reset the form using javascript.
For instance...<af:resetActionListener/> does it in jsff
I need similar implementationOne solution could be calling a backing bean method from client and reset the form in the backing bean method.
var customEvent = new AdfCustomEvent(evt.getSource(),"resetFormEvent",null, true);
customEvent.preventUserInput();
customEvent.queue(true); -
The livecycle designed form has javascript to send the form to 4 recipients. The form worked fine until the mail domain was hosted by gmail (uses TLS, port 587). Now recipients get a MIME email, not the attached PDF. Old versions of the form pre-sept 29 work fine. If we change the form or copy it, it does not work. If we use a different smtp server to test, it works fine, all 4 recipients get the pdf. Any advice is much appreciated! I'd say gmail is the problem, but then why do old forms work fine still through gmail?
the setup is Adobe Livecycle Designer ES4, Adobe Acrobat XI, Outlook 2007, gmail hosted company domain (ex. yourdomain.com), using SMTP port 587 TLS, javascript in the email to declare a PDF, and a button to run the javascript (not a submit button, the javascript does the submit action).
problem looks like this:
EARLY WORKS - PHASE 5, PILING - Change Order 888
Date: Fri, 9 Jan 2015 13:08:55 -0600
Message-ID: <002e01d02c3f$b802fdf0$2808f9d0$@ca>
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_NextPart_000_002F_01D02C0D.6D688DF0"
X-Mailer: Microsoft Office Outlook 12.0
Thread-Index: AdAsP5IQYfLzQOmBQKGrI/ckRv3akg==
Content-Language: en-ca
This is a multi-part message in MIME format.
------=_NextPart_000_002F_01D02C0D.6D688DF0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
The contract has been adjusted by Change Order attached. Please retain copy
for your file records. No hardcopy will be issued by mail.
------=_NextPart_000_002F_01D02C0D.6D688DF0
Content-Type: application/pdf;
name="2785-5 Change Order TEST-Jeff-888.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="2785-5 Change Order TEST-Jeff-888.pdf"
JVBERi0xLjcNJeLjz9MNCjI1NiAwIG9iag08PC9MaW5lYXJpemVkIDEvTCAxMDc2MTkyL08gMjYx
L0UgMTA1MjQ1Ni9OIDEvVCAxMDc1ODI1L0ggWyA3MTQgMzI5XT4 etc...First of all, a drop-down menu doesn't allow for multiple item selection. You'll need a list-box field for that.
Once you have that set up you can use the value(s) selected in this field as the recipients of the email. -
How to set a pop up calendar control in pdf form using javascript?
I'd like to add a pop up calendar control in a PDF form using Adobe Javascript.
The user should be able to select a date from the calendar control.
Awaiting a solution at the earliest.Let's say I did provide you with a solution... Wouldn't that be a "third-party solution" as well?
These tools are not compiled, you know. You have direct access to their source-code and can make sure they don't do anything else beside what they're supposed to do. -
WL 8.1 BEA-101083 error when submitting a form using javascript (IE only)
Hello,
I have a JSP page that is submitting a form with javascript document.form.submit()
after checking the validity of form element values, but I randomly get a BEA-101083
error. The jsp page has worked fine for several year in IPlanet, and Sun One
7 application server, but when ported over to WebLogic 8.1 SP2 the error manifests
itself. Basically, when user submits the form, the next page is displayed with
null values, and soon after the following stack trace appears in the server log.
This error only occurs when the client browser is IE, Netscape works fine.
Thanks,
-Colin
<WLS Kernel>> <> <BEA-101083> <Connection failure.
java.io.IOException: A complete message could not be read on socket: 'weblogic.servlet.internal.MuxableSocketHTTP@9bb9300
- idle tim
eout: '30000' ms, socket timeout: '30000' ms', in the configured timeout period
of '60' secs
at weblogic.socket.SocketMuxer$TimeoutTrigger.trigger(Lweblogic.time.common.Schedulable;)V(SocketMuxer.java:775)
at weblogic.time.common.internal.ScheduledTrigger.run()Ljava.lang.Object;(ScheduledTrigger.java:243)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Lweblogic.security.subject.AbstractSubject;Ljava.security.Privil
egedAction;)Ljava.lang.Object;(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(Lweblogic.security.acl.internal.AuthenticatedSubject;Lweblogic.security.a
cl.internal.AuthenticatedSubject;Ljava.security.PrivilegedAction;)Ljava.lang.Object;(SecurityManager.java:118)
at weblogic.time.common.internal.ScheduledTrigger.executeLocally()V(ScheduledTrigger.java:229)
at weblogic.time.common.internal.ScheduledTrigger.execute(Lweblogic.kernel.ExecuteThread;)V(ScheduledTrigger.java:223)
at weblogic.time.server.ScheduledTrigger.execute(Lweblogic.kernel.ExecuteThread;)V(ScheduledTrigger.java:50)
at weblogic.kernel.ExecuteThread.execute(Lweblogic.kernel.ExecuteRequest;)V(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run()V(ExecuteThread.java:170)
at java.lang.Thread.startThreadFromVM(Ljava.lang.Thread;)V(Unknown Source)Checkboxes only submit a value when they are "on"
They submit nothing if they are not selected.
The problem comes - do you interpret no checkbox values as "clear all values" or "leave the values alone"? Struts assumes the latter.
Your form is probably being kept in session?
Try implementing the reset() method of your action form and set its property to be equivalent to no checkboxes selected. -
Acrobat X Form using Javascript problem
I have a Acrobat Form which I originally created in Acrobat 7 Pro that has a button which executes many lines of javascript. In the javascript there is a large if then else statement group that sets a variable.
I have not worked on this form in many years and recently opened the form using Acrobat X Pro and edited all of the javascript code. The problem is that when I save the document and click on the button it is still executing the previous javascript code for some reason. I have looked everywhere I can think of to make sure there is no remnant of the old code left and cannot find any. It seems like there is a cached copy of the old code somewhere that is being used. I have looked in the properties of the button and in the all javascript area of the forms menu and cannot find any reference to the old code.
Any Idea why this is happening?
Nick BThe Javascript code populates a field on the form and the If Then statement sets this value based on the amount in another field. I have changed all of the values in the If Then statement but the button is still using the old values.
I have tried this on three different computers and it will not pick up the new values. -
Addition of fields in Adobe forms using JavaScript or FormCalc
Hi All,
I have a few amount fields in my Adobe form. I want to calculate their sum and show it in another textfield. Any ideas how this is done using JavaScript or FormCalc.???
Thanks and Regards,
SameerHi Sameer,
you cant use JavaScript here in Web Dynpro. But if you want to calculate the sum through a button click that can be done through the Action Handler method.
Suppose you have 2 fields to add whichare field1 and filed2 in the context tree and the sum will be shown in field3 of context tree - all of numeric data type - obviously. So you can do the following in the action handler method.
int sum = wdContext.currentContextElement().getField1() +
wdContext.currentContextElement().getField2();
wdContext.currentContextElement().setFields3(sum);
Regards,
Shubhadip -
Support for dynamic forms using javascript for android tablet
I have some complex multipage pdf forms with javascript functions and calculations made in Acrobat X Standard, I can open and use parts of the form in ezyPDF android app, however the javascript is not fully supported, does anyone know of any plug ins or work arounds to view my forms on an android tablet, my forma have to be stand alone as internet access is not always available.
Regards MikeGet to know CF's structure / array notation. This comes in
very handy when dealing with queries and form fields.
- Form.myFieldName can also be referenced by
Form["myFieldName"]
- MyQuery.myField can also be referenced by
MyQuery["myField"][rowNumber]
Anything in the above example surrounded by quotation makes
can be made dynamic by just adding in a cf variable surrounded by
pound signs:
get_dealer_completion["level_#level_id#"][1] -
Submittin form using javascript
Hi friends
I have used the following javascript method to submit a form using an href from my
JSP
<a href="# onClick="return submitMe(document.item,<%=activeWhse.getBowhse()%">)"
Javascript function is like this
function submitMe(myform,whse){
myform.powhse.value=whse;
myform.submit();
return true;
It does not work on IE 5 but works on IE 5.5 .
Is there any thing wrong on how I am doing it ?
Please advise
Thanks in advance
</a>Try using
submitMe(document.item,<%=activeWhse.getBowhse()%)
Thanx and Regards
Aruneesh -
Populate form using Javascript
I have a form in my website. Can I populate some fields using Javascript ( and not by the user ) ?
Sorry, FormsCentral doesn't support this functionality.
Thanks,
Wenlan -
Sum the values of a text field in a tabular form using JavaScript
Hi Folks.
OK, I put my hands up. I don't know Java script but I'm picking up the basics and I WANT to learn.
Here's my situation.
I have a tabular form which has lots of Standard Report Columns and ONE text field.
I want to sum the values entered in the text field, real time, using Java Script without the need to have a round trip to the database.
I'm guessing this will involve some kind of loop. Once I have that SUM figure I will store it in a hidden item and it will be used for validation when the user submits the form.
If anyone can give me a simple Java Script to do this, or point me in the direction of one, I'd be very grateful.
Many thanks.
Dogfighter.Hi Arie.
Thanks for the link.
That's a great start,
What I've got working so far is the following...
<script type="text/javascript">
function f_calculate_delta(p_this,p_rownum)
var amt = $x(p_this).value;
alert (amt);
var display_item_to_set = 'f08_'+ p_rownum
$x(display_item_to_set).innerHTML = amt
</script>
This is working fine.
Where I'm stuck at the moment is how I can 'get' the value of another cell in the same row. They have all been set up using the APEX_ITEM API with their own unique IDs.
I will continue looking but if you could give me a steer, that would be great.
Many thanks
Simon
PS. APEX 3.1
PPS. Trying to get the value of another row using...
var display_item_to_get = 'f04_'+ p_rownum
var expected_amt = $x(display_item_to_get).value
PPPS. Also tried...
var display_item_to_get = 'f04_'+ p_rownum
var expected_amt = $v(display_item_to_get)
and
var display_item_to_get = 'f04_'+ p_rownum
var expected_amt = $v(display_item_to_get).value
None of which are working at the moment.
Message was edited by:
Dogfighter -
Multi block validation in a form using nested tables
Hi,
I have a tables that contains 3 nested tables plus some other varchar2 columns.
I have created a form with 4 blocks, three of them based on views on the 3 nested tables, the forth containing the other columns from the table.
I have created relationships between the 4th block and each of the first three.
The records in the nested tables (multi record blocks) depend on some values outside them (from the 4th block) and viceversa.
How can I perform the validation?
Thanks,
LeontinI always use child tables rather than nested tables so this might not be applicable, but I like to use a constraint on a materialzed view when I have to validate multiple records or complicated relationships between blocks.
This example is for inserting ranges on separate records and ensuring the start and end values match up:
Re: need some help
Maybe you are looking for
-
HP Pavilion dv6135nr Notebook internal speakers have stopped working. I can hear sounds on headphones but no sound via the internal speakers. A search on HP customer care for my notebook yielded the download recommendation below, even though I had
-
Since my music takes up a lot of space, I've moved my entire iTunes Library to an external hard drive. If I subscribe to iTunes Match, can I upload the music from my external hd or does it need to actually be in my iTunes Library?
-
Difference between File Sharing, Dropbox, and Public Folder?
I have this MBP out front & my Mac Mini in back. I'm comparatively new to networking, altho I've used File Sharing (FS) & Dropbox (Db). It seems now, there are a myriad of ways to sync my two computers. (ICloud is also used, just for Mail & iCal, sin
-
Itunes store wont open since itunes upgrade
Hi - can anyone help? i am unable to open the itunes store since upgrading the itunes to version 9. It all worked ok before. i have tried uninstalling it and reinstalling it and still get the same problem. i have tried all the advice from apple with
-
Hi All I Want *Contact person feild as optional field* in Vendor master dara General Data tab. field status for the said field is optional in all the levels i.e Vendor account group and also in screen layout per activity. Still while creating vendo