Form Validation against DB

Hi,
I have a field to capture the username and would like to validate against the database that it is a valid user before submitting. If not, I will show an error message. Are there any good example of doing that in Apex? Thanks.

Hi
There are several ways you could do this. A simple method would be to add an Item Level Validation on your page for the username field.
1 Click the Create button in the Validations section of the page defniition
2 Select Item level validation
3 Select the username field from the list of page items
4 Select SQLvalidation method
5 Select the Exists type
6 Give the validation a name (eg, Validate username) and select a location for any error message
7 In the Validation setting, enter in something like:
SELECT 1 FROM USERTABLE WHERE UPPER(USERNAME) = UPPER(:P1_USERNAME)and enter in an Error Message - (eg, Invalid username)
8 Select the button that is used to submit the page (eg, SUBMIT)
9 Click Create to finish
Then, whenever the user clicks the Submit button, the vaildation is triggered and an attempt is made to find the username entered in your list of valid usernames - if there is a match, the above SQL will return one row and the validation is deemed to have passed, so the submit takes place. If there isn't a match, no rows will be returned and the validation fails, and the error message is displayed and the submit process stops.
Andy

Similar Messages

  • Form Validation against database - Dreamweaver CS4 Spry

    Hi all,
    I'm trying to figure out how to implement a form validation
    of some fields, let's say a username. I have a form that inserts on
    MySQL table, and when the user is typing the username, after it
    looses the focus on field, validate it if there is a record on
    table with the specified username. If so, validation will fail.
    I already saw something similar with this on Dreamweaver MX
    using some extension (because at that time, it did not support
    ajax).
    Kind regards, and thanks in advance.

    I don't have a solution, but you may try posting in the Spry
    Forums, you might get a better response.
    http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid=72&catid=602

  • Localization of form-validation messages in WebDynpro

    Hello all,
    We're trying to solve this issue:
    How to get localized (e.g. Slovak) messages which are result of form validation?
    Situation: there is a context atribute, it's type is a simple type and this attribute is bound to an UI input element. When the form is submitted, every such attribute it's checked against it's simple-type.
    So the question is how to get these messages - when validating automatically - for example:
      "Enter the value in the format 25.11.1987"
    in defined language? Is there a way how to configure/translate them?
    Thanks a lot!!
    Rado

    Hi Radoslav,
    You need use Message Pool for showing any data in the WEB Dynpro Applicaiton screen for intenationalization.
    Please refer to this link might help in you scenario :
    [Developing International Web Dynpro Applications|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-technology/wd%20java/wdjava%20archive/internationalization%20of%20web%20dynpro%20applications.pdf]
    Hope it helps
    Regards
    Arun

  • XML instance validation against XML schema

    How can I get a reference on the error node object after
    validation against an XML schema ?
    Ex. :
    DOMParser domP = new DOMParser();
    domP.setXMLSchema(schemaDoc); // schemaDoc = ref. on an XMLSchema
    domP.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    domP.parse(reader); // reader contains the XML instance data
    If an error occurred, I only get a message string. What I need is to get a reference on the node object which contains the error in order to retrieve its properties to the schema.
    I could then alert the user with a message such as :
    "Data xxx is not valid ; it must be comprised between yy and zz...".
    Did somebody solve this problem ? May I use the XMLError class to do this ?
    Thank you

    Hi Ray,
    Were you able to resolve this issue? I am encountering a very similar problem where I am not connected to the internet and it fails during the newSchema method on javax.xml.validation.SchemaFactory. I have attempted to implement the suggestions of ExtremeGardener and vidyut with no luck.
    Per ExtremeGardener's suggestion of replacing xmlns:xs="http://www.w3.org/2001/XMLSchema" with xmlns:xs="XMLSchema.xsd" and storing it locally, it gave me an error for trying to set the "xs" or "xsd" prefixes to anything other than "http://www.w3.org/2001/XMLSchema." I forget the exact error. I also tried to use my own prefix and it did not like that either.
    Per vidyut's suggestion of using a catalog resolver, I believe that I have tried that too (if I understand correctly). I created an LSResourceResolver and tied it to the SchemaFactory. I can invoke it for a namespace but that did not resolve the issue because it only invokes the resolver on an import, include, or redefine. I believe that it is trying to reach the internet due to the xmlns:xs="http://www.w3.org/2001/XMLSchema" attribute within the top-level schema element in the XSD and I know of no way to invoke it for that.
    I also created an ErrorHandler and tied it to the SchemaFactory. That shows me the errors and they are all related to the standard XML data types defined in XMLSchema.xsd. The errors that I am seeing are all of this form: "UndeclaredPrefix: Cannot resolve 'xs:string' as a QName: the prefix 'xs' is not declared."
    I am currently using the SchemaFactory in Java 1.5, but I am thinking about trying the Xerces SchemaFactory since they are not exactly the same implementation.
    Does anyone have any other suggestions? Any help you can provide would be greatly appreciated!
    Thanks,
    betzro1

  • Tabular Form Validation not working in tabular form APEX 4.0

    Hi,
    I am using APEX 4.0. I have a tabular form with Tabular form validation done with it.
    Item not null is the validation.. so if I dont type any value in the any of the fields in the tabular form and press the Submit button, the first time error is shown... but when I click the Submit button again, with still the empty rows the page is submitted.
    How to resolve this issue?
    Edited by: Suzi on Oct 5, 2010 11:13 AM

    Look at this thread - Re: Validations of tabular forms in 4.0

  • Is there a way to bypass the form Validation

    I'm getting really upset with the Coldfusion built-in form validation for any HTML formfield ending by _date , _required, _time and so on...
    My application proposes to the users to create some Properties for an object and later on to modify the values for all these properties.
    I've got a piece of code building dynamically some form fields named just like the properties (by a simple cfloop on a DB query getting the property list).
    And a registering page to records the new value in the DB.
    But it crashes onto the classical "
    Form entries are incomplete or invalid.
    I can't control what the users set as property name (one of them was Checklist_required).
    Is there any way to prevent this error by disabling this auto validation ?
    (I'd like to avoid having to rename any field dynamically created and rename any forms variables before registering them on the DB : it's just NO WAY for me to rename the properties created by the users)

    Fober1, that's not how it works.  It's pretty much the ultimate example of the disjoint between how HTML forms work and how the naive CFML Cfform / cfinput design wished they work.
    When a request is being processed by the coldfusion server, it just looks at the list of FORM (POST) variable names (whether it came from cfform or not; URL/GET params are exempt), and for those with certain suffixes (_date, _required, etc.), and it assumes their existence is intended to request validation another field without that suffix.  It doesn't actually know or care whether form submission, nor the HTML rendered in the user's browser, actually came from "cfform" or "cfinput".   The composition of the request that comes in (when a user clicks on "submit", or a hacker uses any tool imaginable) is out of the server's hands.  The cfform code is not used during form submission processing, because the receiving template (the form action="this_one.cfm") doesn't even have to be the same template that has the cfform in it. There could be multiple conflicting cfforms directing users to request the same template on a single site, with or without the validation, even without considering what a whole other person might decide to send to your server.
    The fact that it can work as intended for a typical user is irrelevant, because the purpose of validation is to deal with the atypical situation.  A malicious or merely mischievous user that wanted to circumvent the validation would simply modify a copy of the page to leave out the "validation request" fields.    For the developer to truly validate the input, additional code must be written, making the feature not only inadequate, but a complete waste of time.  There absolutely should be a way to disable it at worst; Ideally, it would be taken out of coldfusion completely.  It's not only useless, it's a security risk, wooing programmers to write code that doesn't do what they think it does.
    The error message it gives isn't so great, either, and it's a pity that it can't show more than one validation message at a time, either.  If more than one input is invalid, you could end up going through one round after another of submit + back button.
    edit: I forgot to add the other important reason that this feature should never have existed: It is a nuisance to everyone else who doesn't want to use it at all, too!  Those suffixes simply couldn't have been a worse choice, colliding with probably thousands of peoples' variable names.  Why not "*_cfval_date" "*_cfval_time" etc?

  • Form validation working on one page, but not the other....

    Hope someone can help with this.
    I have a page below with a load of contact forms which all work fine :
    http://www.goodsafariguide.com/judges/judges.php
    I've trued to recreate (admittedly mostly by saving as....) the same functionality here :
    http://www.goodsafariguide.com/awardssite/judges/
    They do work when fulled in correctly, but there's a glitch with the validation.
    Basically when you fill in a form incorrectly, the page reloads, with the form's accordion closed. When you open it up, its showing the ugly looking error at the top of the form.
    Any ideas what's causing it to act like this, as opposed to the way it works in the first link?
    Thanks.

    Iain71 wrote:
    I've trued to recreate (admittedly mostly by saving as....) the same functionality here :
    http://www.goodsafariguide.com/awardssite/judges/
    They do work when fulled in correctly, but there's a glitch with the validation.
    When looking at the source code I note that - unlike the first page - this one doesn´t contain any references to the ADDT form validation libraries ("../includes/tng/scripts/FormValidation.js" and "../includes/tng/scripts/FormValidation.js.php"), meaning that the validation can´t work.
    Cheers,
    Günter

  • What is your strategy for form validation when using MVC pattern?

    This is more of a general discussion topic and will not necessarily have a correct answer. I'm using some of the Flex validator components in order to do form validation, but it seems I'm always coming back to the same issue, which is that in the world of Flex, validation needs to be put in the view components since in order to show error messages you need to set the source property of the validator to an instance of a view component. This again in my case seems to lead to me duplicating the code for setting up my Validators into several views. But, in terms of the MVC pattern, I always thought that data validation should happen in the model, since whether or not a piece of data is valid might be depending on business rules, which again should be stored in the model. Also, this way you'd only need to write the validation rules once for all fields that contain the same type of information in your application.
    So my question is, what strategies do you use when validating data and using an MVC framework? Do you create all the validators in the views and just duplicate the validator if the exact same rules are needed in some other view, or do you store the validators in the model and somehow reference them from the views, changing the source properties as needed? Or do you use some completely different strategy for validating forms and showing error messages to the user?

    Thanks for your answer, JoshBeall. Just to clarify, you would basically create a subclass of e.g. TextInput and add the validation rules to that? Then you'd use your subclass when you need a textinput with validation?
    Anyway, I ended up building sort of my own validation framework. Because the other issue I had with the standard validation was that it relies on inheritance instead of composition. Say I needed a TextInput to both check that it doesn't contain an empty string or just space characters, is between 4 and 100 characters long, and follows a certain pattern (e.g. allows only alphanumerical characters). With the Flex built in validators I would have to create a subclass or my own validator in order to meet all the requirements and if at some point I need another configuration (say just a length and pattern restriction) I would have to create another subclass which duplicates most of the rules, or I would have to build a lot of flags and conditional statements into that one subclass. With the framework I created I can just string together different rules using composition, and the filter classes themselves can be kept very simple since they only need to handle a single condition (check the string length for instance). E.g. below is the rule for my username:
    library["user_name"] = new EmptyStringFilter( new StringLengthFilter(4,255, new RegExpFilter(/^[a-z0-9\-@\._]+$/i) ) );
    <code>library</code> is a Dictionary that contains all my validation rules, and which resides in the model in a ValidationManager class. The framework calls a method <code>validate</code> on the stored filter references which goes through all the filters, the first filter to fail returns an error message and the validation fails:
    (library["user_name"] as IValidationFilter).validate("testuser");
    I only need to setup the rule once for each property I want to validate, regardless where in the app the validation needs to happen. The biggest plus of course that I can be sure the same rules are applied every time I need to validate e.g. a username.
    The second part of the framework basically relies on Chris Callendar's great ErrorTipManager class and a custom subclass of spark.components.Panel (in my case it seemed like the reasonable place to put the code needed, although perhaps extending Form would be even better). ErrorTipManager allows you to force open a error tooltip on a target component easily. The subclass I've created basically allows me to just extend the class whenever I need a form and pass in an array of inputs that I want to validate in the creationComplete handler:
    validatableInputs = [{source:productName, validateAs:"product_name"},
                         {source:unitWeight, validateAs:"unit_weight", dataField:"value"},
                   {source:unitsPerBox, validateAs:"units_per_box", dataField:"value"},
                        {source:producer, validateAs:"producer"}];
    The final step is to add a focusOut handler on the inputs that I want to validate if I want the validation to happen right away. The handler just calls a validateForm method, which in turn iterates through each of the inputs in the validatableInputs array, passing a reference of the input to a suitable validation rule in the model (a reference to the model has been injected into the view for this).
    Having written this down I could probably improve the View side of things a bit, remove the dependency on the Panel component and make the API easier (have the framework wire up more of the boilerplate like adding listeners etc). But for now the code does what it needs to.

  • Using XSL on XML validated against XSD

    Transforming XSD validated XMLType Data
    Re: example XSL in Chapter 6 that transforms XML with associated XSD schema definition (Oracle 9i XML Database Developer's Guide)
    I noted that this XSL uses only the "general" node identification functions (e.g., name() ) to access nodes in the <xsl:value-of select..>. I have also noted that standard XSL templates from other sections of the documentation, for example in Chapter 3 and in Appendix D, do not work with an XML which is validated against an XSD schema.
    Can anyone give me an example <xsl:value-of select..> that addresses a specific node in the "purchase order" example, like the shipTo, name, street -- or any other specific node. This is critical since there is always bound to be node-specific processing in any transformation, and this is not demonstrated by any example of XML which has been validated against an XSD.
    I have tried this endlessly on my own examples of XML w/XSD validation. Even if the value-of select="name(.)" tells you that the name of the node is "FooBar", you cannot use FooBar as a select test to do FooBar specific processing.
    Help?????

    Not quite understand your question. Can you send me the example doc?

  • Script for Form validator in head causes error

    When I use the Window/Behaveiors/ to create a form validator, Dreamweaver CS5 puts script in the Head of page, and seems to work ok. But when I validate page with W3c it says there are errors with code and as Dreamweaver created this I have no idea what to do to put right, so could someone please help. This is code generated by Dreamweaver, all other pages have past with flying colors!
    <script type="text/javascript">
    function MM_validateForm() { //v4.0
      if (document.getElementById){
        var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
        for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
          if (val) { nm=val.name; if ((val=val.value)!="") {
            if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
              if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
            } else if (test!='R') { num = parseFloat(val);
              if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
              if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
                min=test.substring(8,p); max=test.substring(p+1);
                if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
          } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
        } if (errors) alert('The following error(s) occurred:\n'+errors);
        document.MM_returnValue = (errors == '');
    </script>

    If the script is working fine in all browsers, you could put it in an external JS file and link to it, then the W3C validator won't find an error.
    If you don't know already, learn about how to do this:
    http://www.hypergurl.com/jsfiles.html

  • Submit by email not working as form validation failed.

    Ive created a form with mulitple pages. Three pages require form validation.
    Each page is a unique process so I'm trying to use the "Submit button" to only submit that
    particular page. I've created dummy fields as defaults to cure the validation problem but
    can't seem to get the e-mail button to work. I also created a email dummy button with the
    scripting:
    EmailSubmitButton.execEvent("click");
    I did this to try to force the the form to be sumitted via PDF. I am a novice at this so please
    help. I'd be happy to send the form as well for review

    You may need to enable usage rights in your form. You must have version 8 to do this. Open the form in Acrobat Pro (not Livecycle), click on Advanced tab, then select "enable usage rights in Adobe Reader"

  • Can Acrobat be made to verify one form field against another?

    Here is an interesting problem, and I'm wondering if Acrobat has the functionality to solve it.
    The sales department is holding up application processing time.  They either forget to fill in blocks of information, or they misspell the buyer's name (Billy on page 1 and William on page 4). 
    Can Acrobat be programmed to verify one form field against another in order to eliminate these errors?
    Thank you.

    I had considered this as well.
    That solution would work in an ideal situation.  In this situation, however, it would probably not be a final workable solution.  Consider the case above.  This organization needs the full legal name on the application.  However, in the first field our friendly sales department enters Billy (instead of William).  If the "duplicate field" solution was embraced, Billy would automatically be embedded and a denial instantly triggered.
    If one form field can be verified against another, then can I assume various formulas could be generated from that?
    If field A then (B and C and D)
    If not field E (then no B and no C)
    Is this also correct?

  • Form Validations

    How to perform form validations in ADF. And also can i customize the behaviour of "Required" property of a UIComponent? I dont want alert boxes to be shown Can i change that?

    you might want to think about using one of the popup LOV item types for your employee ID field. popup LOVs are great for cases where you don't want to weigh your page down w/large lists of values. about your validation, if you really want to do it client-side, then javascript's probably the way to go (search google for code). if you do that, though, let the record show that you'd have to fetch your valid values down to your page for your comparison logic, anyhow. i'd consider using a regular htmldb validation for your emp id field. you seemed concerned in your post with the page submission. i'm assuming that's because you didn't want processing to occur unless the validation passes. if that's the case, fear not, it's a simple matter to set your processing to occur only after your validations have passed. check out the available "Process Point"s and "Computation Point"s for htmldb Processes and Computations to see what i mean.
    hope this helps,
    raj

  • XML validation against XSD

    Hi,
    Does Oracle 8i (Release 3) support XML validations against XSD? I know Oracle 9i (Release 2) supports XML validations against XSD.
    Also, Does Oracle support XML validations against XDR?
    Any info is appreciated.
    Thanks
    Pavan

    Validate with DOMParser or the SAXParser.

  • XML validation against DTD.. Is it possible?

    Hello all,
    Sorry for what may be a trivial post, but I'll keep it short..
    According to the docs:
    "The Validate XML command will validate the XML against the schema defined in the XML file. This command on the context menu is disabled whenever an XML file does not have an XML namespace defined."
    I'm used to the XML editor retrieving a DTD from somewhere and validating it against that.. is it possible to do this in JDev?

    Unfortunately it's not. We only have support for validating against XML Schemas.
    Rob

Maybe you are looking for