Home » Developer & Programmer » Forms » Validation for form Items on client side--- Urgent Plz...
icon9.gif  Validation for form Items on client side--- Urgent Plz... [message #153309] Sat, 31 December 2005 03:37 Go to next message
srinivasocp
Messages: 91
Registered: December 2005
Location: INDIA
Member
Dear All,

I am new to this site and I really appreciate the great job

of this site, helping to share lots of Ideas.

I have a basic doubt. Please help me to clear this.

I am using Forms 6i.

-> I have created a form on dept table.The fields are

deptno,dname,location based on DB table dept with columns

deptno number(3),dname varchar2(10),location varchar2(10)

So from my form even if i am entering the value, for example

XYZ for deptno field and 12345 for dname and 3333 for location

field, these values are getting stored in the dept table.

-> Now I don't want this to happen. I want to do a validation(client side validation)

that prevents the user from entering the character value for

deptno and number's for character fields i.e., dname and

location here.

How can I do this? What Form triggers shuld I have to use? Where shuld I write the

code?


Any help will be higly appreciated.

Thnx & Regards
Srini...


Re: Validation for form Items on client side--- Urgent Plz... [message #153311 is a reply to message #153309] Sat, 31 December 2005 04:20 Go to previous messageGo to next message
RJ.Zijlstra
Messages: 104
Registered: December 2005
Location: Netherlands - IJmuiden
Senior Member
To validate the item:
Use your mouse and select the desired item. Use right button, go to smart triggers, take 'WHEN-VALIDATE-ITEM'.

On record level use when-validate-record.

Also check the help for the following triggers:
key-commit
pre-insert
pre-update

HTH,

Happy New Year
Re: Validation for form Items on client side--- Urgent Plz... [message #153312 is a reply to message #153309] Sat, 31 December 2005 05:02 Go to previous messageGo to next message
srinivasocp
Messages: 91
Registered: December 2005
Location: INDIA
Member
Dear Zijlstra,

I want to know the code to be written in that trigger to

carry on the validation. I like to know what code to write to

allow only numeric values in the deptno item and only character

inputs for dname and location.

Please let me know.



Thnx & Regards
srini...
Re: Validation for form Items on client side--- Urgent Plz... [message #153327 is a reply to message #153312] Sat, 31 December 2005 10:44 Go to previous messageGo to next message
RJ.Zijlstra
Messages: 104
Registered: December 2005
Location: Netherlands - IJmuiden
Senior Member
Ok, startfrom here: The item is (let say) 'Block.Itemname'

Get to the property of Block.Itemname. Put the item data type to numeric. Run the form; put a character in ( 'a' ) Hit enter:
status bar will give you FRM-50016. And the item will not accept the value.

If you want something more user friendly:


For a number field
In the When Validate Trigger:

Declare
v_number number;
Begin
v_number := to_number( :Block.itemname );
Exception
when others then
**** Put your user friendly message here
raise from_trigger_failure;
End;

For a characterfield:

This is a bit difficult to answer, because I don't know if a character value of '123' is considerd a number or not in your application.

If this is considered a number then:

Declare
v_number number;
Begin
v_number := to_number( :Block.itemname );
-- it goes ok, so it is a number, which is not allowed
**** Put your user friendly message here
raise from_trigger_failure;
Exception
when others then
--ok, it raised an error, so it cannot be a number: continue
null;
End;

Ok, HTH

Regards and a heppay New Year

(Of to the champagne and fireworks now...)

Re: Validation for form Items on client side--- Urgent Plz... [message #153344 is a reply to message #153327] Sat, 31 December 2005 19:14 Go to previous messageGo to next message
srinivasocp
Messages: 91
Registered: December 2005
Location: INDIA
Member
Dear Zijlstra


Thnx a lot for ur response. Let me try this out and tell u

the result.







Regards
srini....
Re: Validation for form Items on client side--- Urgent Plz... [message #153539 is a reply to message #153344] Tue, 03 January 2006 01:21 Go to previous messageGo to next message
RJ.Zijlstra
Messages: 104
Registered: December 2005
Location: Netherlands - IJmuiden
Senior Member
Good morning Srini,

(At least here it is morning).
Well, after you try this, sit back and think for a while about what we have done now.
We deleted a record and then put an exact copy back...
Don't you think this is a bit funny, to say the least? I answered your question and this will work, but of course -as another member already pointed out- it is not a good solution at all.

I think you must seriously rethink your strategy / table design / and maybe your database design.

If you cannot change it then instead of a pre-update trigger, you might look at the WHEN-VALIDATE-RECORD trigger. Study the docs and I'm sure you will see very quick that this could be a better solution.

Also you might look at the table itself and -if possible- make a pre-update trigger on the table itself. If you got a DUP_VAL_ON_INDEX exception, you might consider raising an application-error you can gracefully use in the form to display a message. Look up the PRAGMA EXCEPTION_INIT text in the HELP.

I think this will be a much better solution, because now you made sure that any update from any source ( not only from your form ) will be validated. I always try to validate on the db level, and you can tons of docs on the net why to do this.

Hope to have given you some usefull points,
(And ask again if nec.!)

Regards,

Rob Zijlstra
Re: Validation for form Items on client side--- Urgent Plz... [message #153872 is a reply to message #153539] Wed, 04 January 2006 10:01 Go to previous messageGo to next message
srinivasocp
Messages: 91
Registered: December 2005
Location: INDIA
Member
Dear Zijlstra

I can't Understand what ur talking about.My Question is

different.LOOK into my first posting. What solution u suggested

hasn't worked. Let me know if u any other solution.





Regards

srini..



Re: Validation for form Items on client side--- Urgent Plz... [message #153876 is a reply to message #153872] Wed, 04 January 2006 10:10 Go to previous messageGo to next message
srinivasocp
Messages: 91
Registered: December 2005
Location: INDIA
Member
Hi Guys,



Please help me to find a solution for my posting. It is simple

and many of u might have come through a situation like this.


I am again repeating my QUest..



I am using Forms 6i.

-> I have created a form on dept table.The fields are

deptno,dname,location based on DB table dept with columns

deptno number(3),dname varchar2(10),location varchar2(10)

So from my form even if i am entering the value, for example

XYZ for deptno field and 12345 for dname and 3333 for location

field, these values are getting stored in the dept table.

-> Now I don't want this to happen. I want to do a validation(client side validation)

that prevents the user from entering the character value for

deptno and number's for character fields i.e., dname and

location here.

How can I do this? What Form triggers shuld I have to use?

Where shuld I write the

code?





Any help will be higly appreciated.

Thnx & Regards
Srini...
Re: Validation for form Items on client side--- Urgent Plz... [message #153878 is a reply to message #153872] Wed, 04 January 2006 10:23 Go to previous messageGo to next message
RJ.Zijlstra
Messages: 104
Registered: December 2005
Location: Netherlands - IJmuiden
Senior Member
Srini,

Whoops....

The mess starting with 'Good morning' had nothing to do with your original qst. I'm sorry for the confusion.

Did you test :


Declare
v_number number;
Begin
v_number := to_number( :Block.itemname );
Exception
when others then
**** Put your user friendly message here
raise from_trigger_failure;
End;

etc?

Regards and once more sorry , stupid of me

Rob Zijlstra

Re: Validation for form Items on client side--- Urgent Plz... [message #153914 is a reply to message #153344] Wed, 04 January 2006 18:17 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
srinivasocp,

Please STOP pressing the CR-LF at the end of each 70 character line, the system will wrap the text FOR you.

Please STOP with the extra blank lines, these threads get long enough without extraneous blank lines in them.

David
Re: Validation for form Items on client side--- Urgent Plz... [message #154066 is a reply to message #153878] Thu, 05 January 2006 10:16 Go to previous messageGo to next message
srinivasocp
Messages: 91
Registered: December 2005
Location: INDIA
Member
Dear Zijlstra,

It has not worked at all.If u have some other idea please test it and let me know.It is very urgent.

Regards
srini...

[Updated on: Thu, 19 January 2006 16:33] by Moderator

Report message to a moderator

icon13.gif  Re: Validation for form Items on client side--- Urgent Plz... [message #154574 is a reply to message #153309] Mon, 09 January 2006 08:26 Go to previous messageGo to next message
srinivasocp
Messages: 91
Registered: December 2005
Location: INDIA
Member
HI

CAn someone Please help me with my requirement.....

Regards
srini...

[Updated on: Thu, 19 January 2006 16:34] by Moderator

Report message to a moderator

Re: Validation for form Items on client side--- Urgent Plz... [message #154636 is a reply to message #154574] Mon, 09 January 2006 21:11 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Edit your posts to remove the blank lines or I will stop assisting you.

David
Re: Validation for form Items on client side--- Urgent Plz... [message #155917 is a reply to message #153309] Thu, 19 January 2006 12:05 Go to previous messageGo to next message
srinivasocp
Messages: 91
Registered: December 2005
Location: INDIA
Member
Hi Djmartin..
I am very soory . I will not do it again. Can u now help me with my requirement. PLease.. I have posted it long back.

Regards
srini..
Re: Validation for form Items on client side--- Urgent Plz... [message #155946 is a reply to message #155917] Thu, 19 January 2006 16:39 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
These are basic questions so I suggest that you work your way through the Forms demonstration white paper which can found on or from http://www.oracle.com/technology/sample_code/products/forms/index.html.

If you want a field to be numeric define it as a number field in the property sheet of the Forms Builder. Alternatively you can make the department field be based on an LOV which is a list of the available departments or a fixed list that you create. There are no triggers for you to write to do this.

Please remember that Forms Does the Work FOR you. This is not VB where you have to do all the work yourself.

Try that and then come back with your next issue - but in this thread, don't start another one.

David
Previous Topic: How can i attach cleander with Text item.
Next Topic: Application hangs when i Save second time
Goto Forum:
  


Current Time: Fri Sep 20 06:58:12 CDT 2024