Multiple TextField Validation
I want to do this:
I have 3 textfields, when I click the submit button I want
the validation to check whether there's data in any of the
textfields (at least in one) if so, then all three textfields are
Valid, if non of the textfield have data then all 3 textfields are
invalid.
Is this posible in Spry Framework 1.6.1; if so how is this
done?
I tried a custom validating function with option isRequired:
false on and off without luck.
Ok.Well I cannot provide link to the full page as the site is
not up and running yet. However, here's the full html code;
ofcourse you need to update the link to the spry code. I am using
spry 1.6.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Untitled Document</title>
<script src="../SpryAssets/SpryValidationTextField.js"
type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css"
rel="stylesheet" type="text/css" />
</head>
<body>
<form id="brochurereq" name="brochurereq" method="post"
action="test.html">
<input type="submit" value="Send" name="Send" />
<span id="text1">
<input type="text" name="firstname" id="firstname" />
<span class="textfieldRequiredMsg">The value is
required.</span>
</span>
<span id="text2">
<input type="text" name="lastname" id="lastname" />
<span class="textfieldRequiredMsg">The value is
required.</span>
</span>
</form>
<script type="text/javascript">
<!--
var sprytext1 = new Spry.Widget.ValidationTextField("text1",
"none");
var sprytext2 = new Spry.Widget.ValidationTextField("text2",
"none");
//-->
</script>
<body>
</body>
</html>
Similar Messages
-
UI Datepicker and Spry textfield Validation
Hi, I am having a problem with using the UI Date picker and Spry textfield Validation together. I have created a sample form: 2 input boxe, the test box has the datepicker and spry validation and test2 has the date picker only,one submit button and some php code that echos the boxes values on submit.
My date picker is date formated as 'yy-mm-dd' for four digit year. My spry validation is formated 'yyyy-mm-dd' with validate on submit.
Now when I click on the test input box the datepicker comes up normally and i select a date. I then select the date on test2. Once I click the submit button the test field with spry validation come back saying a value is required and nothing else happens.
I was playing around and trying other things to get it to work and I noticed that when I select the test inputbox and the calander pops up if I enter some numbers into the text box then select a date from the datepicker then enter a date in the test2 inputbox and hit submit it works.
So it appears to me that the validation is not reading anything in the test field when I just select a date. Why is that? When I select a date it shows a date in the inputbox. It makes it hard to use the datepicker on a form.
Any help would be a preciated. Code is below.
Thanks Winrol
<?php echo "Test box 1 value = ". $_POST['test']. "<br/>" ?>
<?php echo "Test box 2 value = ". $_POST['test2'] ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script src="jquery-ui-1.7.2/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="jquery-ui-1.7.2/js/jquery-ui-1.7.2.min.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="jquery-ui-1.7.2/css/base/ui.core.css" rel="stylesheet" type="text/css" />
<link href="jquery-ui-1.7.2/css/base/ui.datepicker.css" rel="stylesheet" type="text/css" />
<link href="jquery-ui-1.7.2/css/base/ui.theme.css" rel="stylesheet" type="text/css" />
<link href="jquery-ui-1.7.2/css/base/ui.datepicker.images.css" rel="stylesheet" type="text/css" />
<style type="text/css">
/* BeginOAWidget_Instance_2137022: #datepicker */
#datepicker .ui-widget {
font-family: inherit;
#datepicker .ui-datepicker {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
#datepicker .ui-datepicker-title {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 1.1em;
color: #000;
font-weight: normal;
line-height: 1.8em;
#datepicker .ui-state-default, .ui-widget-content .ui-state-default {
border-color: #e6e6e6;
background-color: #e6e6e6;
color: #555555;
#datepicker .ui-state-default, .ui-state-default a {
color: #555555;
#datepicker .ui-state-highlight, .ui-widget-content .ui-state-highlight {
border-color:#FCEFA1;
background-color:#FCEFA1;
color:#363636;
#datepicker .ui-state-active, .ui-widget-content .ui-state-active {
border-color: #FFFFFF;
background-color: #FFFFFF;
color: #212121;
#datepicker .ui-state-hover, .ui-widget-content .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus
border-color: #5F5F5F;
background-color: #5F5F5F;
color: #212121;
#datepicker .ui-widget-header
border-color: #5F5F5F;
background-color: #808080;
border-width: 1px;
/* Text attributes for the Days of Week Text */
#datepicker .ui-datepicker table th
font-size: .8em;
color: #000;
font-weight: bold;
/* EndOAWidget_Instance_2137022 */
</style>
<script type="text/xml">
<!--
<oa:widgets>
<oa:widget wid="2137022" binding="#datepicker" />
</oa:widgets>
-->
</script>
<script type="text/javascript">
// BeginOAWidget_Instance_2137022: #datepicker
$(function() {
$('input').filter('.datepicker').datepicker({dateFormat: 'yy-mm-dd'});
// EndOAWidget_Instance_2137022
</script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
background-color: #FFC;
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p>
<label for="test">test</label>
<span id="sprytextfield1">
<input name="test" type="text" class="datepicker" id="test"/>
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></p>
<p>
<label for="test2">test2</label>
<input name="test2" type="text" id="test2" class="datepicker" />
</p>
<p onclick="<?php echo $_POST['test'] ?>">
<input type="submit" name="submit" id="submit" value="Submit" />
</p>
</form>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "date", {format:"yyyy-mm-dd", hint:"yyyy-mm-dd"});
</script>
</body>
</html>This does work
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet">
<link href="jquery-ui-1.7.2/css/base/ui.core.css" rel="stylesheet">
<link href="jquery-ui-1.7.2/css/base/ui.datepicker.css" rel="stylesheet">
<link href="jquery-ui-1.7.2/css/base/ui.theme.css" rel="stylesheet">
<link href="jquery-ui-1.7.2/css/base/ui.datepicker.images.css" rel="stylesheet">
</head>
<body>
<form action="" method="post">
<span id="sprytextfield1">
<label for="mydate">Date:</label>
<input id="datepicker" name="mydate" type="text">
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
<div id="datepicker" class="ui-glass-gradient ui-80TopTo0Bottom-gradient-header"></div>
<input name="mysubmit" type="submit">
</form>
<script src="SpryAssets/SpryValidationTextField.js"></script>
<script src="jquery-ui-1.7.2/js/jquery-1.3.2.min.js"></script>
<script src="jquery-ui-1.7.2/js/jquery-ui-1.7.2.min.js"></script>
<script>
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "date", {format:"mm/dd/yyyy", validateOn:["change"], useCharacterMasking:true});
$(function() {
$('#datepicker').datepicker({ showOtherMonths: false });
</script>
</body>
</html>
Gramps -
Hi, how can I modify this code for the spry textfield validation.js file? My text field is set to yyyy-mm-dd. When I enter a date and hit the submit button all works well but, how can I modify this portion of the .js file so the date yyyy-mm-dd is not less than today's date?
===================
'date': {
validation: function(value, options) {
var formatRegExp = /^([mdy]+)[\.\-\/\\\s]+([mdy]+)[\.\-\/\\\s]+([mdy]+)$/i;
var valueRegExp = this.dateValidationPattern;
var formatGroups = options.format.match(formatRegExp);
var valueGroups = value.match(valueRegExp);
if (formatGroups !== null && valueGroups !== null) {
var dayIndex = -1;
var monthIndex = -1;
var yearIndex = -1;
for (var i=1; i<formatGroups.length; i++) {
switch (formatGroups[i].toLowerCase()) {
case "dd":
dayIndex = i;
break;
case "mm":
monthIndex = i;
break;
case "yy":
case "yyyy":
yearIndex = i;
break;
if (dayIndex != -1 && monthIndex != -1 && yearIndex != -1) {
var maxDay = -1;
var theDay = parseInt(valueGroups[dayIndex], 10);
var theMonth = parseInt(valueGroups[monthIndex], 10);
var theYear = parseInt(valueGroups[yearIndex], 10);
// Check month value to be between 1..12
if (theMonth < 1 || theMonth > 12) {
return false;
// Calculate the maxDay according to the current month
switch (theMonth) {
case 1: // January
case 3: // March
case 5: // May
case 7: // July
case 8: // August
case 10: // October
case 12: // December
maxDay = 31;
break;
case 4: // April
case 6: // June
case 9: // September
case 11: // November
maxDay = 30;
break;
case 2: // February
if ((parseInt(theYear/4, 10) * 4 == theYear) && (theYear % 100 != 0 || theYear % 400 == 0)) {
maxDay = 29;
} else {
maxDay = 28;
break;
// Check day value to be between 1..maxDay
if (theDay < 1 || theDay > maxDay) {
return false;
// If successfull we'll return the date object
return (new Date(theYear, theMonth - 1, theDay)); //JavaScript requires a month between 0 and 11
} else {
return false;
======================
Thanks WinrolV1 Fusion wrote:
> Yes you can use regular expessions:
>
> function validatePhone(value){
> return
>
/^(((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((\+44\s?\d{3}|\(?0\d{3}\)?)\s?
>
\d{3}\s?\d{4})|((\+44\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3})
> )?$/.test(value)
> }
>
> var custom = new Spry.ValidationTextField(id, "custom",
{validation:
> validatePhone, validateOn:["blur", "change"]})
>
> regexp from
http://regexlib.com/
Excellent, thank you, that will get me in the right
direction. Its not
100%, but I think I can tinker with an expression to get what
I want.
The number is couldn't handle is +44 (0)113 255 7666 but its
not an
approved format anyway, but lots of companies still do it
this way, so I
want to ensure I get it right.
Thanks again!
Dooza
Posting Guidelines
http://www.adobe.com/support/forums/guidelines.html
How To Ask Smart Questions
http://www.catb.org/esr/faqs/smart-questions.html -
Error in TextField Validation Widget reset() method
There appears to be an error in the Textfield Validation
Widget's reset() method. When I set the widget to "real" or
"custom" validation, the reset() method is throwing an error when
it reaches the line "this.oldValue = this.input.defaultValue;"
I seached the code and it appears that
"this.input.defaultValue" is not set anywhere else. Is there a
missing option, or is this line incorrect and copied over from
another widget that uses "defaultValue"?It looks as though you're trying to use main-content as a CSS selector. If it's a class, it should begin with a dot (period) like this:
.main-content
If it's an ID selector, it should begin with a hash:
#main-content -
TextField Validation in swings
Hello friends,
i got a problem. i am doing textfield validation using KeyListener.
i can able to detect the keys except Tab key.
When i am pression TAB key the KeyListener is not catching the event.
Actually validation should be in such a way that,
in account number field if i press anyotherkeys otherthan numeric ,del,backspace keys it should not allow to enter.
also it has to give error if user tries to move from that field without entering anydata by pressing TAB or Mouse.
Here exactly getting problem with focus.
Please give your advise
thanks in advance
regards
shashiTextField Validation in swingsOk, you know its a Swing question, so it should be posting in the Swing forum.
if i press anyotherkeys otherthan numeric ,del,backspace keys it should not allow to enter.You should be using a JFormattedTextField
it has to give error if user tries to move from that field without entering anydata You could try an InputVerifier. -
TextField validation with multiple options
Hi.
I am trying to create a textField widget that can have a
number of possible correct answers. Can anyone let me know if this
is possible. I have successfully created a textField that validates
one answer with the use of Type Custom, but i am unsure how to have
multiple correct answers for one textField.
Thanks
Barry.Hi Barry,
to validate more values inside the textfield widget, you have
to create your custom regular expression that fits with what values
you accept for that input field.
So your contructor should look similar with this:
var sprytextfield1 = new
Spry.Widget.ValidationTextField("sprytextfield1", "custom",
{regExpFilter:/test1|test2|test3/, useCharacterMasking:true});
This regexp is translated: the textfiled will accept only
test1, test2, test3 values.
You can also have this behavior if you create a custom
function having a set of switch values:
switch(){
case1: ...
case2:...
default:false
and you call this function as option in the widget
constructor.
Diana -
Multiple field validation under one form
I have one form and in that form i need to validate multiple inputText fields. Each inputText field has its own button for an input assistance that would later populate that particular inputText field. When i click on one of those buttons the entire page (all fields) gets validated. Does this happen because they are all under one FORM? do we have a better way of doing this and does adding inputHidden after each field fix this? im really new at this JSF. thanks.
If you don't have any required="true" fields, then let your custom validator check which button was pressed by determining the presence of the button in the RequestParameterMap. If your search button has a client ID of for example "formId:searchButtonId", then do something like in the validator:if (FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().containsKey("formId:searchButtonId")) {
// validate input for search.
}You can even pass the client ID as f:attribute along the UIInput field if you want.
The following two articles aren't strictly what you need, but it might give useful background information:
Action dependent requireness: http://balusc.blogspot.com/2007/12/action-dependent-requireness.html
f:attribute and validator: http://balusc.blogspot.com/2007/12/validator-for-multiple-fields.html -
Function to call spry textfield validation
Hi every body.
I've a question for you.
I'm using a filed spry text field validation. It works perfectly when y press submit, but I need to do this:
I put some text in a textfield using PHP, the validation is only maked when I click the text field, or when the user press a key, but how to make a function to do the validation after I put data on textfield.Click the on Blur as per
Gramps -
Best solution for multiple field validation
Hi
I am using jdeveloper 11r2 (11.1.2.3.0) & JSF2 Facelet
What is best way to validate multiple field is same time?
In my use case I have address component and there is a dependensy between suburb ,posrcode and state fiels
How I can implement this in ADF?What is the best way working in ADF?
As I know using <f:validator > we can validate one field each time
Appreciate any suggestion or comments
MohsenWrite entity level method validator
-
Urgent Pls... Textfield validation
Hi All,
In a textfield its should accept two conditions i.e.,
1) It should accept 10 digits or
2) In a field it should accept two chars and 5 digits. or than that its should pop up an alert.
I have tried setting patterns and worte the script in exit event:
if(this.rawValue == this.formattedValue)
xfa.host.setFocus(this.name);
But the setFocus is going again and again.
Patterns: text{AA99999}|text{9999999999}
Please help.
Thanks in advance
Regards,
ApurvaHi Apurva,
You need regular expression for this. Remove all the validations of the text field first i.e display,edit,validation,data.
In the exit event of the field put the following script.
var vPattern = /^([a-zA-Z]{2}[0-9]{5})$|^([0-9]{10})$/;
var result = vPattern.test(this.rawValue);
if (result == false)
xfa.host.setFocus(this.name);
Thanks,
Bibhu. -
Textfield validation with XML Data
hello
can i validation a textfield with data from a XML file?
i will read eg usernames form an XML file and will check it
with a username was typed in in a textfield,
if the username exits the textfield is invalid, since the
username was typed in, is not in the XML file.
thanks
jackHello,
I don't advise you to make such an scenario. The solution you
propose involve some high security risks and privacy problems
because you send to the browser a complete list of users of your
website.
The Spry Validation Textfield supports callback validation
javascript function. This means you create your own function that
include the necessary code to validate the user input and pass to
the widget as parameter the name of your function. A good sample of
this feature could be seen in the
Password
Validation section.
Regards,
Cristian -
Multiple field validation failures
Hi,
I am working on 7.11 and working on SOAP to Proxy (sync) scenario.
I have gone through XML validation document provided by SAP in which i came to know that only first error will be sent back.
Please let me know how to handle all the errors at once with / without XML validation.
Thanks
HamjaI have gone through XML validation document provided by SAP in which i came to know that only first error will be sent back.
Yes the check wont be done for the rest of the file if some earlier node is found missing.
Please let me know how to handle all the errors at once with / without XML validation.
Using BPM it can be done....but a strict No from my side to use this option.
there is even a blog mentioning the use of JAVA mapping for schema validation but then it also stops processing when it finds the first missing node.
Regards,
Abhishek. -
Force Textfield Validation??
Hello,
I am using the Spry Text Field Validation widget to validate
my username field in a registration form. On blur, it checks to see
if the username exists. Is there a function I can call from that
checking function to classify that field as invalid?
(Make it turn pink and pop up a custom error message)
I tried to do this manually, but then the spry validation
doesn't work anymore.
I suppose it would be similar to the spry:states feature;
that you could manually classify the field as 'maxchars' or
'invalidFormat', or in my case, 'usernameTaken'...
Thanks alot in advance,
MaquellyHi Maquelly,
You have to use a custom validation to do this. Your custom
validation function needs to return true if it passes validation
and false if it doesn't. kjuliff did something like this already
which you can use as an example. Look at these related posts.
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=72&catid=602&threadid =1231854&enterthread=y
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=72&catid=602&threadid =1248092&enterthread=y
I'll file a bug to make sure we have a sample that can walk
folks through this.
--== Kin ==-- -
Is it possible to set multiple textfield value with a for=loop
JTextField W1HourTF=new JTextField(8);
JTextField W2HourTF=new JTextField(8);
JTextField W3HourTF=new JTextField(8);
JTextField W4HourTF=new JTextField(8);
I have created the above 4 textfields, I want to set all the text field editable using a for loop.
Is there any method which can do it? Example :
for (i=0,i<=4,i++)
WHourTF.setEditable(true); // where i is based on the loop timeimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.border.*;
class JTEXTFIELD extends JFrame
JTextField [] jTextFieldArray = {jTextField1, jTextField1, jTextField2, jTextField3};
========================================================================
How come I get error :
JTEXTFIELD.java:9: cannot resolve symbol
symbol : variable jTextField1
location: class JTEXTFIELD
JTextField [] jTextFieldArray = {jTextField1, jTextField1, jTextField2,
jTextField3}; -
Hi all,
The way the application works is the user has to input more
than one field at a time before he or she hits the Enter key. Is
there a way to validate multiple fields only at the end of an input
screen as oppose to having to validate each field one at a time ?
Thanks in advance.The way I would approach this is to make each field validate
with the pressing of the TAB key, with the last field requiring the
pressing of the ENTER key to validate the typed entry. Assign these
keys in the shortcuts options within the text entry field
properties.
The text entry fields set to 'continue', each set to appear
after each other, so the first field is completed and TAB pressed,
assuming the typed entry is correct the slide continues, and then
displays the second field and prompts the user to type in the
second field etc onwards until the last field which requires a
typed entry then the pressing of the enter key or clicking a button
from your screen shot (with click box overlaid). Alternatively, do
this over several slide with the same screenshot, with each text
entry box set to 'go to next slide' when correct, which displays
the same screen shot but with the first field completed and the
second field awaiting an entry to be made..
That make sense?
Maybe you are looking for
-
Report for Open Inboin Deliveries
Hi I would like to have report for Open Inbound Deliveries. for which NO GRN is made Pl update ASAP Manoj
-
Access denied to NetPoint.PaymentProviderImplementation.dll
Hello, I have set up the Bussiness One E-commerce and I have a problem when I am trying to make an order. After I press continue after the "Billing" step, the text below appears: An Internal Error has occurred. Version 2007.1.650.0 Message
-
When i try to down load flash player it says it can't create a temp folder.
when i try to down load flash player it says it can't create a temp folder. What do I do now?
-
Calling ALV grid in class method
Is it possible to call a ALV grid display in a class~method. I thought, I would call a screen and make a ALV grid display using the control frame work,it is no possible to call screen inside a method. Then i tried to avoid calling the screen.. data:
-
SES, TREX ... and search in indexed table
Hi I have a task, to use SES to create intarface (in ABAP) for search in one specyfic table. This table contains field with long description text and I would like to use SES to search over it. I read some documents and i checked SAP Help ... but i st