LijaHarris
3 years agoQrew Cadet
CODE PAGE: Javascript OnInput Function with Resulting Prompt or Alert (No UPS needs to Be QuickBase/Code Page Native!
Hi,
I have a code page where users can input their information and it goes directly into QuickBase in Javascript and HTML. Our clients were wondering if a prompt could be given to users if they entered in a zip code that is not in their service area - like the Zip Code is not found in their LIST. Here is what I have so far but it is not working. As can be seen below, the fid is 16 of the field users input their zip code into. Zip Code is my LIST the client gave me (I gave a couple examples). I believe the OnChange is not working and instead should be OnInput? I would like the promp to ideally happen oninput instead since its a input field. For reference zip field (fid 16) would be what the user inputs. Otherwise is ther another way to get the user's input, check if its included in a LIST, and if not have text or a Pop up or Alert?:
<script lang="javascript">
function CheckForZip
{
var zipcode = [94602,95616]
var inputzip = "<field fid='16'>" + $("input[name=_fid_16]").val() + "</field>";
if (zipcode.includes(inputzip)) {
alert ('yes');
}
}
On the form:
<tr><td style="font-family: Sans-serif;" class=m>Zip Code:*</td>
<td class=m><input type=text size=60 onChange=CheckForZip name=_fid_16 ></td></tr>
------------------------------
Lija Harris
------------------------------
I have a code page where users can input their information and it goes directly into QuickBase in Javascript and HTML. Our clients were wondering if a prompt could be given to users if they entered in a zip code that is not in their service area - like the Zip Code is not found in their LIST. Here is what I have so far but it is not working. As can be seen below, the fid is 16 of the field users input their zip code into. Zip Code is my LIST the client gave me (I gave a couple examples). I believe the OnChange is not working and instead should be OnInput? I would like the promp to ideally happen oninput instead since its a input field. For reference zip field (fid 16) would be what the user inputs. Otherwise is ther another way to get the user's input, check if its included in a LIST, and if not have text or a Pop up or Alert?:
<script lang="javascript">
function CheckForZip
{
var zipcode = [94602,95616]
var inputzip = "<field fid='16'>" + $("input[name=_fid_16]").val() + "</field>";
if (zipcode.includes(inputzip)) {
alert ('yes');
}
}
On the form:
<tr><td style="font-family: Sans-serif;" class=m>Zip Code:*</td>
<td class=m><input type=text size=60 onChange=CheckForZip name=_fid_16 ></td></tr>
------------------------------
Lija Harris
------------------------------