Sie sind auf Seite 1von 4

********************************** Phone number validation**********************

******************
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (!isLoading){
if(newValue.length ==10){
if( (newValue != "") && (/[0-9]{10}/i.test(newValue)) ) {
} else {
alert("number should only be 10 digits");
g_form.setValue('u_ip_phone_number','');
// g_form.showErrorBox('phone',"The phone number must be in this format: 9865
989658.\n");
}
}
else{
//g_form.showErrorBox('phone',' number should only be 10 digits');
alert("number should only be 10 digits");
g_form.setValue('u_ip_phone_number','');
}
}
}
******************************** MAC address validation*************************
***************
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (!isLoading){
if( (newValue != "") && (/^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i.test(newV
alue)) )
{
} else {
//g_form.showErrorBox('ip_add',"The phone number must be in this format: xxx
.xxx.xxx.xxx\n");
alert("ip add should only be 00:00:00:00:00:00 to ff:ff:ff:ff:ff:ff ");
g_form.setValue('u_mac_address_1','');
}
}
******************************** letter validation******************************
**********
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (!isLoading){
if( (newValue != "") && (/^[a-zA-Z ]*$/i.test(newValue)) )
{

} else {
//g_form.showErrorBox('ip_add',"msg");
alert("name should only be character ");
g_form.setValue('u_name','');
}
}
}
******************************** IP address validation**************************
**************
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (!isLoading){
if( (newValue != "") && (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2
[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2
[0-4][0-9]|[01]?[0-9][0-9]?)$/i.test(newValue)) )
{
} else {
//g_form.showErrorBox('ip_add',"The phone number must be in this format: xxx
.xxx.xxx.xxx\n");
alert("ip add should only be 0.0.0.0 to 255.255.255.255 ");
g_form.setValue('u_mac_address_1','');
}
}
}
*****************************************Automatic fetch value based on a field*
***********************
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading)
return;
if (newValue == '') {
g_form.setValue('u_user_first_name', '');
g_form.setValue('u_user_last_name', '');
return;
}
if (!g_form.getControl('u_user_first_name'))
return;
if (!g_form.getControl('u_user_last_name'))
return;
var user = g_form.getReference('u_user_racf', setDetails);
}
function setDetails(user) {

if (user)
g_form.setValue('u_user_first_name', user.first_name);
g_form.setValue('u_user_last_name', user.last_name);
}
*****************************************date validation************************
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var today = new Date();
var end = new Date(newValue);
var intToday = (today.getUTCFullYear() * 10000) + (today.getUTCMonth() * 100)
+ today.getUTCDate();
var intEnd = (end.getUTCFullYear() * 10000) + (end.getUTCMonth() * 100) + end.
getUTCDate();
//clear the message
g_form.hideFieldMsg(control.name);
//Use UTC conversion, and verify each part is appropriate
if (intEnd >= intToday) {
//this is valid, do nothing
} else {
//g_form.showFieldMsg(control.name,'End date must be in the future.','error');
alert("date sholud we today or future date");
g_form.clearValue(control.name);
}
}
******************************** numeric validation*****************************
***********
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (!isLoading){
if( (newValue != "") && (/^[0-9]+$/i.test(newValue)) )
{
} else {
//g_form.showErrorBox('ip_add',"msg");
alert("name should only be character ");
g_form.setValue('u_name','');
}
}
}
******************************************serial number***********************
/^[\s\da-zA-Z\-.\/]+$/

************************alpha numeric*******************
/^[0-9a-zA-Z]+$/

Das könnte Ihnen auch gefallen