Html 如何在coldfusion中检查字符串中是否包含字符 警报('开始键号必须大于结束键号!请重新输入');
我有两个文本框,用户可以在其中输入字母数字键号(如M1000)和数字键号(如1000)。我能够处理字母数字键值,同时生成自动递增的键值Html 如何在coldfusion中检查字符串中是否包含字符 警报('开始键号必须大于结束键号!请重新输入');,html,coldfusion,Html,Coldfusion,我有两个文本框,用户可以在其中输入字母数字键号(如M1000)和数字键号(如1000)。我能够处理字母数字键值,同时生成自动递增的键值 但是对于像1000这样的数字键条目,上面的操作失败了,因为我正在删除不存在的字符,并且该条目不被接受。请告知我是否可以使用refind()函数查找字符串条目中是否有字符。谢谢ReFind是一个合适的函数,但是在使用变量x之前,您正在覆盖它。在这里,您为x指定一个值 <td><input type="text" MAXLENGTH="5" <
但是对于像1000这样的数字键条目,上面的操作失败了,因为我正在删除不存在的字符,并且该条目不被接受。请告知我是否可以使用refind()函数查找字符串条目中是否有字符。谢谢ReFind是一个合适的函数,但是在使用变量x之前,您正在覆盖它。在这里,您为x指定一个值
<td><input type="text" MAXLENGTH="5" <cfif isdefined ("saverecord1") and isdefined("form.startnum") and form.startnum neq ''>value="#form.startnum#" <cfelse>value=""</cfif> onkeyup="toupper(this)" name="startnum" id="startnum"></td>
<td><input MAXLENGTH="5"type="text" <cfif isdefined ("saverecord1") and isdefined("form.endnum") and form.endnum neq ''>value="#form.endnum#" <cfelse>value=""</cfif> onkeyup="toupper(this)" name="endnum" id="endnum"></td>
<cfset x = #REFind('[^a-z]', '#form.startnum#')# >
<cfset x = "#form.startnum#">
<cfif Len(Trim(x)) GT 0>
<cfset x = RemoveChars(x,1,1)>
</cfif>
<cfset y = "#form.ENDNUM#">
<cfif Len(Trim(y)) GT 0>
<cfset y = RemoveChars(y,1,1)>
</cfif>
<cfif y gt x>
<cfset total = y - x>
<cfelse>
<script>
alert('Starting key number has to be greater than the ending key number! Please enter again');
</script>
</cfif>
然后将另一个值赋给x
<cfset x = #REFind('[^a-z]', '#form.startnum#')# >
然后使用变量:
<cfset x = "#form.startnum#">
该cfif与
<cfif Len(Trim(x)) GT 0>
但你可能想要这个:
<cfif Len(Trim(form.startnum)) GT 0>
ReFind是一个合适的函数,但在使用变量x之前,您将覆盖它。在这里,您为x指定一个值
<td><input type="text" MAXLENGTH="5" <cfif isdefined ("saverecord1") and isdefined("form.startnum") and form.startnum neq ''>value="#form.startnum#" <cfelse>value=""</cfif> onkeyup="toupper(this)" name="startnum" id="startnum"></td>
<td><input MAXLENGTH="5"type="text" <cfif isdefined ("saverecord1") and isdefined("form.endnum") and form.endnum neq ''>value="#form.endnum#" <cfelse>value=""</cfif> onkeyup="toupper(this)" name="endnum" id="endnum"></td>
<cfset x = #REFind('[^a-z]', '#form.startnum#')# >
<cfset x = "#form.startnum#">
<cfif Len(Trim(x)) GT 0>
<cfset x = RemoveChars(x,1,1)>
</cfif>
<cfset y = "#form.ENDNUM#">
<cfif Len(Trim(y)) GT 0>
<cfset y = RemoveChars(y,1,1)>
</cfif>
<cfif y gt x>
<cfset total = y - x>
<cfelse>
<script>
alert('Starting key number has to be greater than the ending key number! Please enter again');
</script>
</cfif>
然后将另一个值赋给x
<cfset x = #REFind('[^a-z]', '#form.startnum#')# >
然后使用变量:
<cfset x = "#form.startnum#">
该cfif与
<cfif Len(Trim(x)) GT 0>
但你可能想要这个:
<cfif Len(Trim(form.startnum)) GT 0>
用通俗易懂的英语你的目标是什么?确保form.startNum
ie1000
的数字部分不超过form.endNum
?与您的问题无关,但不需要任何#
标志,除了
标签内的标志。此外,您还可以通过使用cfparam
设置默认form
值,然后删除isDefined
语句来简化代码。您的目标是什么?确保form.startNum
ie1000
的数字部分不超过form.endNum
?与您的问题无关,但不需要任何#
标志,除了
标签内的标志。此外,您还可以通过使用cfparam
设置默认form
值,然后删除isDefined
语句来简化代码。