Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Validation question

Participant ,
Aug 07, 2008 Aug 07, 2008
I know how to get the maximum of a field but how can I get a max & minimum value for a form field.
Let's say I have a serialnumber field thet needs exactly 10 characters. I need it to be exactly 10 characters.
Is this done via javaScript or can it be done with CFScript?

I want to thank you in advance,
Gene
725
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 07, 2008 Aug 07, 2008
Little better:

<cfsavecontent variable="checklength">
if(serialnumber.length != 10)
{
alert("Serial Number must be 10 characters!", "Serial Number Error");
submit.enabled = false;

}
else
{
submit.enabled = true;

}
</cfsavecontent>

<cfform format="flash" id="myForm" name="myForm" method="post"
action="somepage.cfm">
<p>
<cfinput type="text" name="serialnumber" id="serialnumber"
onBlur="#checklength#" />
</p>
<p>
<cfinput type="submit" id="mysubmitSubmit" name="submit" value="Submit" ...
Translate
LEGEND ,
Aug 07, 2008 Aug 07, 2008
javascript
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 07, 2008 Aug 07, 2008
Huh?

I am confused. What are you talking about here Dan?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 07, 2008 Aug 07, 2008
Your OP contained exactly one question. My reply answered it.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 07, 2008 Aug 07, 2008
http://www.webmaster-talk.com/javascript-forum/26724-check-size-of-input.html

And you should do it server-side too.

<cfif Len(Trim(FORM.yourfield)) NEQ 10>
Your error code here
</cfif>

--
Ken Ford
Adobe Community Expert Dreamweaver/ColdFusion
Fordwebs, LLC
http://www.fordwebs.com


"Gene Godsey" <webforumsuser@macromedia.com> wrote in message
news:g7erlv$h57$1@forums.macromedia.com...
>I know how to get the maximum of a field but how can I get a max & minimum
> value for a form field.
> Let's say I have a serialnumber field thet needs exactly 10 characters. I
> need it to be exactly 10 characters.
> Is this done via javaScript or can it be done with CFScript?
>
> I want to thank you in advance,
> Gene
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 07, 2008 Aug 07, 2008
Then let me clarify Dan,

I am using Flash forms from CF7.2.
The existing Javascript code that was here does not work.
-----------------------------------<script type='text/javascript'>
function lengthRestriction(elem, min, max){
var uInput = elem.value;
if(uInput.length >= min && uInput.length <= max){
return true;
}else{
alert("Please enter 10 EDI Numbers");
elem.focus();
return false;
}
}
</script>
<form>
<input type='text' id='restrict' maxlength="10"/>
<input type='button'
onclick="lengthRestriction(document.getElementById('restrict'), 10, 10)"
value='Check Field' />
</form>
--------------------------------------

Is there a solution for flash forms?
I hope that will clarify my question.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 07, 2008 Aug 07, 2008
Ken,
The business request is to NOT wait for server side validation.
That is a business rule that is out of my hands.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 07, 2008 Aug 07, 2008
Wow don't do Flash forms so this is a SWAG from reading this:

http://www.adobe.com/devnet/coldfusion/articles/adv_flashforms.html

<cfsavecontent variable="checklength">
if(serialnumber.length != 10)
{
submit.enabled = false;
}
else
{
submit.enabled = true;
}
</cfsavecontent>

<cfform format="flash" id="myForm" name="myForm" method="post"
action="somepage.cfm">
<p>
<cfinput type="text" name="serialnumber" id="serialnumber"
onchange="#checklength#" />
</p>
<p>
<cfinput type="submit" id="mysubmitSubmit" name="submit" value="Submit"
enabled="false" />
</p>
</cfform>

--
Ken Ford
Adobe Community Expert Dreamweaver/ColdFusion
Fordwebs, LLC
http://www.fordwebs.com


"Gene Godsey" <webforumsuser@macromedia.com> wrote in message
news:g7f36v$pap$1@forums.macromedia.com...
> Then let me clarify Dan,
>
> I am using Flash forms from CF7.2.
> The existing Javascript code that was here does not work.
> -----------------------------------<script type='text/javascript'>
> function lengthRestriction(elem, min, max){
> var uInput = elem.value;
> if(uInput.length >= min && uInput.length <= max){
> return true;
> }else{
> alert("Please enter 10 EDI Numbers");
> elem.focus();
> return false;
> }
> }
> </script>
> <form>
> <input type='text' id='restrict' maxlength="10"/>
> <input type='button'
> onclick="lengthRestriction(document.getElementById('restrict'), 10, 10)"
> value='Check Field' />
> </form>
> --------------------------------------
>
> Is there a solution for flash forms?
> I hope that will clarify my question.
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 07, 2008 Aug 07, 2008
Little better:

<cfsavecontent variable="checklength">
if(serialnumber.length != 10)
{
alert("Serial Number must be 10 characters!", "Serial Number Error");
submit.enabled = false;

}
else
{
submit.enabled = true;

}
</cfsavecontent>

<cfform format="flash" id="myForm" name="myForm" method="post"
action="somepage.cfm">
<p>
<cfinput type="text" name="serialnumber" id="serialnumber"
onBlur="#checklength#" />
</p>
<p>
<cfinput type="submit" id="mysubmitSubmit" name="submit" value="Submit"
enabled="false" />
</p>
</cfform>


--
Ken Ford
Adobe Community Expert Dreamweaver/ColdFusion
Fordwebs, LLC
http://www.fordwebs.com


"Ken Ford" <newsgroups2@fordwebs.com> wrote in message
news:g7f4ao$qih$1@forums.macromedia.com...
> Wow don't do Flash forms so this is a SWAG from reading this:
>
> http://www.adobe.com/devnet/coldfusion/articles/adv_flashforms.html
>
> <cfsavecontent variable="checklength">
> if(serialnumber.length != 10)
> {
> submit.enabled = false;
> }
> else
> {
> submit.enabled = true;
> }
> </cfsavecontent>
>
> <cfform format="flash" id="myForm" name="myForm" method="post"
> action="somepage.cfm">
> <p>
> <cfinput type="text" name="serialnumber" id="serialnumber"
> onchange="#checklength#" />
> </p>
> <p>
> <cfinput type="submit" id="mysubmitSubmit" name="submit" value="Submit"
> enabled="false" />
> </p>
> </cfform>
>
> --
> Ken Ford
> Adobe Community Expert Dreamweaver/ColdFusion
> Fordwebs, LLC
> http://www.fordwebs.com
>
>
> "Gene Godsey" <webforumsuser@macromedia.com> wrote in message
> news:g7f36v$pap$1@forums.macromedia.com...
>> Then let me clarify Dan,
>>
>> I am using Flash forms from CF7.2.
>> The existing Javascript code that was here does not work.
>> -----------------------------------<script type='text/javascript'>
>> function lengthRestriction(elem, min, max){
>> var uInput = elem.value;
>> if(uInput.length >= min && uInput.length <= max){
>> return true;
>> }else{
>> alert("Please enter 10 EDI Numbers");
>> elem.focus();
>> return false;
>> }
>> }
>> </script>
>> <form>
>> <input type='text' id='restrict' maxlength="10"/>
>> <input type='button'
>> onclick="lengthRestriction(document.getElementById('restrict'), 10, 10)"
>> value='Check Field' />
>> </form>
>> --------------------------------------
>>
>> Is there a solution for flash forms?
>> I hope that will clarify my question.
>>
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 07, 2008 Aug 07, 2008
LATEST
This last bit of code is very cool,
Thanks,
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources