Hi Elsabe,
here just a simple example. I have modified the Search.jsp of our Property example that way,
that a small function is testing if the entered value of bedrooms is a number or not:
First I entered a mall amount of javascript code a the top of the page:
<SCRIPT language=Javascript>
<!--
function IsNumeric(sText)
{
var ValidChars = "0123456789.";
var IsNumber=true;
var Char;
for (i = 0; i < sText.length && IsNumber == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
alert(sText+">"+ValidChars.indexOf(Char));
IsNumber = false;
}
}
return IsNumber;
}
function mySubmit(){
if (document.form1.valNoBRFrom.value!="" && "true" == IsNumeric(document.form1.valNoBRFrom.value)){
alert("'From' is not a number!");
return false;
}
if (document.form1.valNoBRTo.value!="" && "true" == IsNumeric(document.form1.valNoBRTo.value)){
alert("'To' is not number!");
return false;
}
document.forms['form1'].submit();
return true;
}
-->
</SCRIPT>
</pre><BR>IsNumeric tests an entered value on numbers and mySubmit does the submit of the form.<BR><BR>Afterwards I have changed the direct submit in the anchor the my own function:<BR> <B>previous:</B><BR> <pre class="ip-ubbcode-code-pre">
<a href="javascript:document.forms['form1'].submit();">
</pre><BR> <B>modifed:</B><BR> <pre class="ip-ubbcode-code-pre">
<a href="javascript:mySubmit();">
Thats all.
I hope this information will help you.
Bye
Thorsten
Search.jsp (16 KB)
#webMethods#API-Management#Tamino