Jump to content
  • 0

Validate cell number


Kendall

Question

Hi. I am a newby. I have a database with cell number being unique. I need to know how we can capture the cell number. If it is found then the client data must display. If the number is not found then the form must be blank so the data capturer can capture the client data. How do I do that?

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Hi, @Kendall. You can create a Details page where you can insert the phone number if it is blank. You may check this How-to articles: 

https://howto.caspio.com/datapages/reports/creating-a-report-datapage/#:~:text=Configuring the Details Page

https://howto.caspio.com/faq/reports-datapages/how-do-i-edit-data-through-my-details-page/

-Potato

Link to comment
Share on other sites

  • 0

Just to add, if you also wish to validate value entered in an input field to make sure that it follows this format: www.websitename.com

Then you can use this code:

 


<script type="text/javascript">

document.addEventListener('BeforeFormSubmit', function(event) {

var inputField = document.querySelector('#InsertRecordNameofField');

  const value = inputField.value;
  const regex = /^www\.[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$/;

if (!regex.test(value)) {
event.preventDefault();
alert('Invalid Submission!');

} else {

document.form["caspioform"].submit();

}

});
</script>

Make sure to replace "NameofField" with the actual name of the field that you want to validate before submitting.

Link to comment
Share on other sites

  • 0

Do you mean like only show the rest of the form if the provided number does not exist on the datapage yet?

In that case, we can use a calculated value and Rules.

On the calculated value, make a formula like this:

The case when (select phone_number from phonebook where phone_number = [@field:Phone_number])

then 1

else 0

end

Then create a rule that will hide the rest of the datapage if the value of the calculated value field is 0.

Link to comment
Share on other sites

  • 0

In addition, you can then use a JS to prevent the submission from going if the returned value from the calculated value is 0.

You can use this forum post: 
 

Just modify it a bit to capture the calculated value.

 

<script type="text/javascript">

document.addEventListener('BeforeFormSubmit', function(event) {

var Input1 = document.querySelector("span[id^='cbParamVirtual1']").innerHTML;

     if (Input1 === ) {
event.preventDefault();

alert('Phone Number already Exist');


} else {

document.forms["caspioform"].submit();

}

});
</script>
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...